Fix and Document parallel_tool_calls
Attribute in ModelSettings
#763
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #762
Description
This PR updates the docstring for the
parallel_tool_calls
attribute in theModelSettings
dataclass to accurately reflect its default behavior.. The previous docstring incorrectly stated that the default ofFalse
, while the actual behavior is dependent on the underlying model provider's default.As noted in OpenAI's (here refers as model provider) Function Calling documentation, "The model may choose to call multiple functions in a single turn. You can prevent this by setting parallel_tool_calls to false, which ensures exactly zero or one tool is called."
Therefore, when the
parallel_tool_calls
attribute in theModelSettings
dataclass is set toNone
(i.e.,parallel_tool_calls: bool | None = None
), and this value is passed directly to the API without modification, it defers to the model provider's default behavior for parallel tool calls. This is typicallyTrue
for most current providers, but it's important to acknowledge that this isn't a fixed default within our codebase.The new docstring is formatted for automatic documentation generation and provides clear, accurate information for users and developers.
Key changes:
parallel_tool_calls
: Instead of stating a fixed default, the docstring now accurately reflects that the behavior defaults to whatever the model provider does when the attribute isNone
.parallel_tool_calls
attribute.Testing:
parallel_tool_calls=False
in both therun_config
of theRunner.run
method and in the agent’smodel_settings
attribute.Runner.run
:parallel_tool_calls=False
, tools are called sequentially.Why this is important:
parallel_tool_calls
.