File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
src/agents/extensions/models Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 4444from ...models .chatcmpl_stream_handler import ChatCmplStreamHandler
4545from ...models .fake_id import FAKE_RESPONSES_ID
4646from ...models .interface import Model , ModelTracing
47+ from ...models .openai_responses import Converter as OpenAIResponsesConverter
4748from ...tool import Tool
4849from ...tracing import generation_span
4950from ...tracing .span_data import GenerationSpanData
@@ -367,15 +368,20 @@ async def _fetch_response(
367368 if isinstance (ret , litellm .types .utils .ModelResponse ):
368369 return ret
369370
371+ # Convert tool_choice from ChatCompletion format to Responses API format
372+ responses_tool_choice = OpenAIResponsesConverter .convert_tool_choice (
373+ model_settings .tool_choice
374+ )
375+ if responses_tool_choice is None or responses_tool_choice is omit :
376+ responses_tool_choice = "auto"
377+
370378 response = Response (
371379 id = FAKE_RESPONSES_ID ,
372380 created_at = time .time (),
373381 model = self .model ,
374382 object = "response" ,
375383 output = [],
376- tool_choice = cast (Literal ["auto" , "required" , "none" ], tool_choice )
377- if tool_choice is not omit
378- else "auto" ,
384+ tool_choice = responses_tool_choice , # type: ignore[arg-type]
379385 top_p = model_settings .top_p ,
380386 temperature = model_settings .temperature ,
381387 tools = [],
You can’t perform that action at this time.
0 commit comments