-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Add tool call arguments in ToolContext for RunHooks #1765
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
Conversation
|
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. |
src/agents/tool_context.py
Outdated
| tool_call_id: str = field(default_factory=_assert_must_pass_tool_call_id) | ||
| """The ID of the tool call.""" | ||
|
|
||
| tool_arguments: Optional[str] = None |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Background
Currently, the
RunHookslifecycle (on_tool_start,on_tool_end) exposes theToolandToolContext, but does not include the actual arguments passed to the tool call.resolves #939
Solution
This implementation is inspired by PR #1598.
tool_argumentsfield toToolContextand populate it via from_agent_context with tool_call.arguments.lifecycle_example.pyto demonstrate tool_arguments in hooks