Skip to content

Conversation

ihower
Copy link
Contributor

@ihower ihower commented Sep 17, 2025

Background

Currently, the RunHooks lifecycle (on_tool_start, on_tool_end) exposes the Tool and ToolContext, but does not include the actual arguments passed to the tool call.

resolves #939

Solution

This implementation is inspired by PR #1598.

  • Add a new tool_arguments field to ToolContext and populate it via from_agent_context with tool_call.arguments.
  • Update lifecycle_example.py to demonstrate tool_arguments in hooks
  • Unlike the proposal in PR #253, this solution is not expected to introduce breaking changes, making it easier to adopt.

@seratch seratch added feature:core enhancement New feature or request labels Sep 18, 2025
@seratch
Copy link
Member

seratch commented Sep 22, 2025

Thanks for the suggestion. I agree this is safer for us to accept than #253; @rm-openai let me know if you have any comments before I merge this within a few business days.

@seratch seratch requested a review from rm-openai September 22, 2025 05:15
tool_call_id: str = field(default_factory=_assert_must_pass_tool_call_id)
"""The ID of the tool call."""

tool_arguments: Optional[str] = None
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you make this non-optional, similar to tool_call_id above?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem, but this will require changes in quite a few test cases, since ToolContext will now always need to be passed a tool_arguments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. I also updated realtime/session.py where ToolContext needs tool_arguments too.

@rm-openai rm-openai merged commit 5e1db14 into openai:main Sep 22, 2025
5 checks passed
seratch added a commit to openai/openai-agents-js that referenced this pull request Sep 26, 2025
seratch added a commit to openai/openai-agents-js that referenced this pull request Sep 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature:core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose tool call arguments in RunHooks on_tool_start and on_tool_end
3 participants