@@ -350,7 +350,9 @@ async def responses_full_generator(
350
350
outputs .append (reasoning_item )
351
351
if message_item :
352
352
outputs .append (message_item )
353
- elif request .tool_choice is None or request .tool_choice == "none" :
353
+ elif (request .tool_choice == "none" and \
354
+ not self .expand_tools_even_if_tool_choice_none ) or \
355
+ request .tool_choice is None :
354
356
# No tool calls.
355
357
if reasoning_item :
356
358
outputs .append (reasoning_item )
@@ -372,7 +374,7 @@ async def responses_full_generator(
372
374
ensure_ascii = False ))
373
375
for tool_call in tool_calls
374
376
])
375
- elif request .tool_choice == "auto" :
377
+ elif request .tool_choice == "auto" or request . tool_choice == "none" :
376
378
try :
377
379
tool_parser = self .tool_parser (tokenizer )
378
380
except RuntimeError as e :
@@ -381,6 +383,7 @@ async def responses_full_generator(
381
383
tool_call_info = tool_parser .extract_tool_calls (
382
384
content if content is not None else "" , request = request )
383
385
if tool_call_info is not None and tool_call_info .tools_called :
386
+ # extract_tool_calls() returns a list of tool calls.
384
387
function_calls .extend (
385
388
FunctionCall (
386
389
name = tool_call .function .name ,
@@ -476,6 +479,7 @@ def _construct_input_messages(
476
479
else :
477
480
for item in request .input :
478
481
if item .get ("type" ) == "function_call" :
482
+ # Append the function call as a tool call.
479
483
messages .append ({
480
484
"role" :
481
485
"assistant" ,
@@ -489,6 +493,7 @@ def _construct_input_messages(
489
493
}]
490
494
})
491
495
elif item .get ("type" ) == "function_call_output" :
496
+ # Append the function call output as a tool message.
492
497
messages .append ({
493
498
"role" : "tool" ,
494
499
"content" : item .get ("output" , "" ),
0 commit comments