Skip to content

Fix and Document parallel_tool_calls Attribute in ModelSettings #763

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Rehan-Ul-Haq
Copy link
Contributor

@Rehan-Ul-Haq Rehan-Ul-Haq commented May 26, 2025

Closes #762

Description

This PR updates the docstring for the parallel_tool_calls attribute in the ModelSettings dataclass to accurately reflect its default behavior.. The previous docstring incorrectly stated that the default of False, 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 the ModelSettings dataclass is set to None (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 typically True 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:

  • Clarified the default behavior of 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 is None.
  • Improved the docstring format for compatibility with documentation tools.
  • Clarified the purpose and usage of the parallel_tool_calls attribute.

Testing:

  • Explicitly set parallel_tool_calls=False in both the run_config of the Runner.run method and in the agent’s model_settings attribute.
  • Example for Runner.run:
Runner.run(agent, input, run_config=RunConfig(model_settings=ModelSettings(parallel_tool_calls=False)))
  • Example for agent initialization:
agent = Agent(..., model_settings=ModelSettings(parallel_tool_calls=False))
  • Verified that when parallel_tool_calls=False, tools are called sequentially.
  • Confirmed that by default (without setting the attribute), tools are called in parallel (Tested with openai models).
  • Checked that the updated docstring renders correctly in the generated documentation.
  • Ensured the default value in code matches the documentation.

Why this is important:

  • Prevents confusion for users and developers regarding the default behavior of parallel_tool_calls.
  • Ensures that generated documentation is accurate and up-to-date.
  • Improves overall code quality and maintainability.

@AmmarAamir786
Copy link

This update perfectly addresses the mismatch—by documenting parallel_tool_calls=True as the real default, it aligns the docs with the code and clears up the confusion. Thanks for fixing this!

@Rehan-Ul-Haq Rehan-Ul-Haq force-pushed the fix/parallel_tool_calls branch from e5c68aa to 1f0915a Compare May 28, 2025 04:49
Copy link
Collaborator

@rm-openai rm-openai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think probably best to say it defaults to whatever the model does (bc that can vary across providers)

@Rehan-Ul-Haq
Copy link
Contributor Author

I think probably best to say it defaults to whatever the model does (bc that can vary across providers)

You're absolutely right. It could be updated like so.

"""
Controls whether the model can make multiple parallel tool calls in a single turn.

If not provided (i.e., set to None), this behavior defers to the underlying
model provider's default
. For most current providers (e.g., OpenAI), this typically
means parallel tool calls are enabled (True).

Set to True to explicitly enable parallel tool calls, or False to restrict the
model to at most one tool call per turn.
"""

@Rehan-Ul-Haq Rehan-Ul-Haq force-pushed the fix/parallel_tool_calls branch from 07cefed to 1f0915a Compare June 1, 2025 04:53
@Rehan-Ul-Haq Rehan-Ul-Haq force-pushed the fix/parallel_tool_calls branch 2 times, most recently from 72d6177 to 4ca3cc0 Compare June 1, 2025 15:26
@Rehan-Ul-Haq Rehan-Ul-Haq force-pushed the fix/parallel_tool_calls branch from 4ca3cc0 to 077c17b Compare June 1, 2025 15:27
@Rehan-Ul-Haq Rehan-Ul-Haq requested a review from rm-openai June 2, 2025 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

parallel_tool_calls default is True in the client, despite docs saying False
3 participants