Skip to content

Commit b978b43

Browse files
authored
Support parallel_tool_calls=False for ChatCompletion API (#513)
The current ChatCompletion API supports only `parallel_tool_calls=True` or `parallel_tool_calls=NOT_GIVEN` This PR is to support setting `parallel_tool_calls=False`, a common requirement in controlling agent tool use patterns (e.g. ensuring one tool call at the time, to facilitate desired tool calling sequence). I followed the merged [PR#333](#333) for consistency.
1 parent 96a97af commit b978b43

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/agents/models/openai_chatcompletions.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,11 @@ async def _fetch_response(
500500
span.span_data.input = converted_messages
501501

502502
parallel_tool_calls = (
503-
True if model_settings.parallel_tool_calls and tools and len(tools) > 0 else NOT_GIVEN
503+
True
504+
if model_settings.parallel_tool_calls and tools and len(tools) > 0
505+
else False
506+
if model_settings.parallel_tool_calls is False
507+
else NOT_GIVEN
504508
)
505509
tool_choice = _Converter.convert_tool_choice(model_settings.tool_choice)
506510
response_format = _Converter.convert_response_format(output_schema)

0 commit comments

Comments
 (0)