A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 14, 05:30 UTC
[gpt-oss] Streaming Output for Python Tool (#23409)
Signed-off-by: zjy0516 <riverclouds.zhu@qq.com>
Jiangyun Zhu committed
Aug 24, 2025 at 12:42 UTC
c55c02899853a31b1a8a0f48b2ca3ea9dae80586
1 file changed
+44
-26
vllm/entrypoints/openai/serving_responses.py
+44
-26
@@ -1069,7 +1069,48 @@ class OpenAIServingResponses(OpenAIServing):
1069
delta=ctx.parser.last_content_delta,
1070
sequence_number=-1,
1071
))
1072
-
1072
+ # built-in tools will be triggered on the analysis channel
1073
+ # However, occasionally built-in tools will
1074
+ # still be output to commentary.
1075
+ elif (ctx.parser.current_channel == "commentary"
1076
+ or ctx.parser.current_channel == "analysis"
1077
+ ) and ctx.parser.current_recipient == "python":
1078
+ if not sent_output_item_added:
1079
+ sent_output_item_added = True
1080
+ yield _send_event(
1081
+ openai_responses_types.
1082
+ ResponseOutputItemAddedEvent(
1083
+ type="response.output_item.added",
1084
+ sequence_number=-1,
1085
+ output_index=current_output_index,
1086
+ item=openai_responses_types.
1087
+ ResponseCodeInterpreterToolCallParam(
1088
+ type="code_interpreter_call",
1089
+ id=current_item_id,
1090
+ code=None,
1091
+ container_id="auto",
1092
+ outputs=None,
1093
+ status="in_progress",
1094
+ ),
1095
+ ))
1096
+ yield _send_event(
1097
+ openai_responses_types.
1098
+ ResponseCodeInterpreterCallInProgressEvent(
1099
+ type=
1100
+ "response.code_interpreter_call.in_progress",
1101
+ sequence_number=-1,
1102
+ output_index=current_output_index,
1103
+ item_id=current_item_id,
1104
+ ))
1105
+ yield _send_event(
1106
+ openai_responses_types.
1107
+ ResponseCodeInterpreterCallCodeDeltaEvent(
1108
+ type="response.code_interpreter_call_code.delta",
1109
+ sequence_number=-1,
1110
+ output_index=current_output_index,
1111
+ item_id=current_item_id,
1112
+ delta=ctx.parser.last_content_delta,
1113
+ ))
1114
if ctx.is_assistant_action_turn() and len(ctx.parser.messages) > 0:
1115
previous_item = ctx.parser.messages[-1]
1116
if (self.tool_server is not None
@@ -1165,30 +1206,6 @@ class OpenAIServingResponses(OpenAIServing):
1206
and self.tool_server.has_tool("python")
1207
and previous_item.recipient is not None
1208
and previous_item.recipient.startswith("python")):
1168
- yield _send_event(
1169
- openai_responses_types.ResponseOutputItemAddedEvent(
1170
- type="response.output_item.added",
1171
- sequence_number=-1,
1172
- output_index=current_output_index,
1173
- item=openai_responses_types.
1174
- ResponseCodeInterpreterToolCallParam(
1175
- type="code_interpreter_call",
1176
- id=current_item_id,
1177
- code="",
1178
- container_id="auto",
1179
- outputs=[],
1180
- status="in_progress",
1181
- ),
1182
- ))
1183
- yield _send_event(
1184
- openai_responses_types.
1185
- ResponseCodeInterpreterCallInProgressEvent(
1186
- type="response.code_interpreter_call.in_progress",
1187
- sequence_number=-1,
1188
- output_index=current_output_index,
1189
- item_id=current_item_id,
1190
- ))
1191
- # TODO: do we need to add delta event here?
1209
yield _send_event(
1210
openai_responses_types.
1211
ResponseCodeInterpreterCallCodeDoneEvent(
@@ -1196,7 +1213,8 @@ class OpenAIServingResponses(OpenAIServing):
1213
sequence_number=-1,
1214
output_index=current_output_index,
1215
item_id=current_item_id,
1199
- code=previous_item.content[0].text))
1216
+ code=previous_item.content[0].text,
1217
+ ))
1218
yield _send_event(
1219
openai_responses_types.
1220
ResponseCodeInterpreterCallInterpretingEvent(