Skip to content

Fix type annotation and clarify tool behavior docs #1355

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 3 commits into from
Aug 3, 2025

Conversation

mshsheikh
Copy link
Contributor

This commit improves type safety by replacing Any with the correct generic type TContext in the get_all_tools method.
It also avoids confusion by renaming the input parameter in the run_agent function to user_input because input is a built-in function in Python.
Lastly, it updates the documentation of tool_use_behavior to clearly describe the use of the StopAtTools object instead of a plain list of tool names.
These changes make the code more accurate, easier to understand, and better aligned with best practices.

… docs

This commit improves type safety by replacing Any with the correct generic type TContext in the get\_all\_tools method.
It also avoids confusion by renaming the input parameter in the run\_agent function to user\_input because input is a built-in function in Python.
Lastly, it updates the documentation of tool\_use\_behavior to clearly describe the use of the StopAtTools object instead of a plain list of tool names.
These changes make the code more accurate, easier to understand, and better aligned with best practices.
Use user\_input instead of input to avoid passing the built-in function by mistake.
@@ -101,7 +101,7 @@ async def get_mcp_tools(self, run_context: RunContextWrapper[TContext]) -> list[
self.mcp_servers, convert_schemas_to_strict, run_context, self
)

async def get_all_tools(self, run_context: RunContextWrapper[Any]) -> list[Tool]:
async def get_all_tools(self, run_context: RunContextWrapper[TContext]) -> list[Tool]:
Copy link
Member

Choose a reason for hiding this comment

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

this is good catch

@seratch seratch added the documentation Improvements or additions to documentation label Aug 3, 2025
@mshsheikh mshsheikh requested a review from seratch August 3, 2025 02:00
@seratch seratch changed the title Fix type annotation, avoid input shadowing, and clarify tool behavior docs Fix type annotation and clarify tool behavior docs Aug 3, 2025
@seratch seratch merged commit 5c73311 into openai:main Aug 3, 2025
5 checks passed
vcshih pushed a commit to veris-ai/openai-agents-python that referenced this pull request Aug 15, 2025
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 feature:core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants