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 1 commit into
base: main
Choose a base branch
from

Conversation

Rehan-Ul-Haq
Copy link

@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. The previous docstring incorrectly stated that the default value is False, while the actual default is True.
In OpenAI docs of section Function Calling, it is clearly mentioned that "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, if 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 effectively behaves as if parallel_tool_calls is set to True.

The new docstring is formatted for automatic documentation generation and provides clear, accurate information for users and developers.

Key changes:

  • Corrected the documented default value of parallel_tool_calls from False to True.
  • 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.
  • 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
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
2 participants