- Notifications
You must be signed in to change notification settings - Fork2k
enhancement: Add tool_name to ToolContext to support shared tool handlers#1043
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
enhancement: Add tool_name to ToolContext to support shared tool handlers#1043
Conversation
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.
Thanks for quickly working on this!
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
… tool_context.from_agent_context, Aligned formatting in _run_impl.py
Thanks for the thoughtful feedback@seratch! I've pushed an update that addresses it..if any changes are needed further, please lmk! |
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.
Once the added### Tool context
document section is deleted and#1048 gets merged, this looks good to me.
@rm-openai Can you take a quick look and share thoughts if you have any?
Uh oh!
There was an error while loading.Please reload this page.
Co-authored-by: Kazuhiro Sera <seratch@openai.com>
befe19d
intoopenai:mainUh oh!
There was an error while loading.Please reload this page.
This is a follow-up to pr#1043 The original changes were reverted dueto missing updates in RealtimeSession, which caused runtime testfailures.This PR:- Reapplies the `tool_name` and `tool_call_id` additions to`ToolContext`.- Updates `RealtimeSession._handle_tool_call` to instantiate`ToolContext` with `tool_name=event.name` and`tool_call_id=event.call_id`.- Adjusts tests as needed so that all 533 tests (including old-versionPython 3.9) pass cleanly.Closes#1030---------Co-authored-by: Kazuhiro Sera <seratch@openai.com>
This adds a
tool_name
field toToolContext
, which gets passed into theon_invoke_tool
handler. Helpful for scenarios where we dynamically register multiple tools that all share a single generic handler e.g.in multi-agent setups.As such, by including the name of the tool that was invoked, the handler can now easily branch logic or route requests accordingly.
Resolves#1030
All tests pass. and here is a script to test it outhttps://gist.github.com/vrtnis/ca354244f7a5ecd9a73c0a2d34cb194b