Skip to content

Enhance Tool Behavior Documentation for Developer Clarity With Examples #1286

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

Merged
merged 7 commits into from
Jul 29, 2025

Conversation

MuhammadHamidRaza
Copy link
Contributor

Enhances the "Tool Behavior Definitions" documentation to provide clearer
explanations and more robust examples for agent tool usage. Previously,
developers often faced challenges and ambiguity in understanding and implementing
these tool behaviors due to insufficient examples and unclear import paths.

Key improvements in this update include:

  • Explicitly defining import paths for StopAtTools and ToolsToFinalOutputFunction.
  • Providing comprehensive and corrected code examples for all tool_choice and
    tool_use_behavior configurations, including "stop_on_first_tool",
    StopAtTools, and the usage of ToolsToFinalOutputFunction.
  • Ensuring proper Markdown formatting for code blocks and notes to enhance
    readability and accuracy.

This update aims to significantly reduce ambiguity and improve the
developer experience by offering ready-to-use and well-explained code snippets.

…l Behavior Definitions" documentation to provide clearer explanations and more robust examples for agent tool usage. Key improvements include: - Explicitly defining import paths for `StopAtTools` and `ToolsToFinalOutputFunction`. - Providing comprehensive and corrected code examples for all `tool_choice` and `tool_use_behavior` configurations, including `"stop_on_first_tool"`, `StopAtTools`, and the usage of `ToolsToFinalOutputFunction`. - Ensuring proper Markdown formatting for code blocks and notes to enhance readability and accuracy. This update aims to significantly reduce ambiguity and improve the developer experience by offering ready-to-use and well-explained code snippets.
@seratch seratch added the documentation Improvements or additions to documentation label Jul 28, 2025
docs/agents.md Outdated
from agents import Agent, Runner, function_tool, ModelSettings

@function_tool
def get_stock_price(ticker: str) -> str:
Copy link
Member

Choose a reason for hiding this comment

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

We would like to avoid this example in the document page. Can you simply reuse the fetch_purchases for these added examples? The main purpose is to share the ways to pass customization options, not to share a variety of examples.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We would like to avoid this example in the document page. Can you simply reuse the fetch_purchases for these added examples? The main purpose is to share the ways to pass customization options, not to share a variety of examples.

Hi, thanks for the review and the valuable feedback!

I've addressed your comments regarding the get_stock_price example and replaced it with get_weather to keep the documentation consistent and focused on demonstrating tool_use_behavior options rather than introducing new tools.

You're absolutely right about the main purpose being to share customization options. My intention with the detailed examples was to ensure that developers can easily understand and implement these advanced behaviors without confusion.

Personally, I've spent a considerable amount of time troubleshooting and experimenting with StopAtTools and ToolsToFinalOutputFunction because clear, runnable examples were not readily available. This led to significant time wastage for me. By providing these simplified yet comprehensive examples directly in the documentation, we can prevent other developers from facing similar challenges, saving them countless hours of debugging and guesswork.

I believe these changes make the documentation much more user-friendly and reduce the friction for anyone integrating with the Agent SDK.

Please let me know if any further adjustments are needed.

This update significantly enhances the "Tool Behavior Definitions" documentation, directly addressing the common challenges and wasted time developers previously experienced. Without clear examples and explicit guidance on import paths and usage patterns, implementing advanced agent tool behaviors was often a source of confusion and trial-and-error.

**Key improvements in this update include:**

-   **Explicitly defining crucial import paths** for `StopAtTools` and `ToolsToFinalOutputFunction`, removing guesswork.
-   **Providing comprehensive and corrected code examples** for all `tool_choice` and `tool_use_behavior` configurations, including `"stop_on_first_tool"`, `StopAtTools`, and `ToolsToFinalOutputFunction`. These examples are now streamlined and use consistent, easy-to-understand tools like `get_weather`.
-   **Ensuring proper Markdown formatting** for code blocks and notes to enhance readability and accuracy.

My personal experience, including significant time spent troubleshooting these very behaviors due to lack of clear examples, fueled this contribution. This update aims to drastically reduce ambiguity and improve the developer experience by offering ready-to-use and well-explained code snippets, saving countless hours for others.
This update significantly enhances the "Tool Behavior Definitions" documentation, directly addressing the common challenges and wasted time developers previously experienced. Without clear examples and explicit guidance on import paths and usage patterns, implementing advanced agent tool behaviors was often a source of confusion and trial-and-error.

**Key improvements in this update include:**

-   **Explicitly defining crucial import paths** for `StopAtTools` and `ToolsToFinalOutputFunction`, removing guesswork.
-   **Providing comprehensive and corrected code examples** for all `tool_choice` and `tool_use_behavior` configurations, including `"stop_on_first_tool"`, `StopAtTools`, and `ToolsToFinalOutputFunction`. These examples are now streamlined and use consistent, easy-to-understand tools like `get_weather`.
-   **Ensuring proper Markdown formatting** for code blocks and notes to enhance readability and accuracy.

My personal experience, including significant time spent troubleshooting these very behaviors due to lack of clear examples, fueled this contribution. This update aims to drastically reduce ambiguity and improve the developer experience by offering ready-to-use and well-explained code snippets, saving countless hours for others.
Copy link
Member

@seratch seratch left a comment

Choose a reason for hiding this comment

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

LGTM

@seratch seratch merged commit d968d7f into openai:main Jul 29, 2025
5 checks passed
vcshih pushed a commit to veris-ai/openai-agents-python that referenced this pull request Aug 15, 2025
…es (openai#1286)

Co-authored-by: Kazuhiro Sera <seratch@openai.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants