You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
enhancement: Add tool_name to ToolContext to support shared tool handlers (#1043)
This adds a `tool_name` field to `ToolContext`, which gets passed into
the `on_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 out
https://gist.github.com/vrtnis/ca354244f7a5ecd9a73c0a2d34cb194b
---------
Co-authored-by: Kazuhiro Sera <seratch@openai.com>
Copy file name to clipboardExpand all lines: docs/tools.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -180,7 +180,7 @@ Sometimes, you don't want to use a Python function as a tool. You can directly c
180
180
-`name`
181
181
-`description`
182
182
-`params_json_schema`, which is the JSON schema for the arguments
183
-
-`on_invoke_tool`, which is an async function that receives the context and the arguments as a JSON string, and must return the tool output as a string.
183
+
-`on_invoke_tool`, which is an async function that receives a [`ToolContext`][agents.tool_context.ToolContext] and the arguments as a JSON string, and must return the tool output as a string.
0 commit comments