-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add tool call parameters for on_tool_start
hook
#253
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
base: main
Are you sure you want to change the base?
Conversation
( | ||
agent.hooks.on_tool_start(context_wrapper, agent, func_tool) | ||
agent.hooks.on_tool_start(context_wrapper, agent, func_tool, tool_call.arguments) | ||
if agent.hooks |
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.
Since using only arguments as a parameter is too granular, and adding tool_call.id in the future would lead to parameter inflation at the root level, plus tool_call.id is actually needed, would it be better to pass the entire tool_call object as a parameter instead?"
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.
@mini-peanut Thanks for your review! I've updated the hook to use Action
, which not only includes the Tool
but also contains the instance information for a tool call, including the parameters and tool_call.id
.
@yanmxa thanks for doing this work, very useful! |
4724b5e
to
c3287fd
Compare
much needed feature! |
I learned that if you use Example: result = Runner.run_streamed(
agent,
input,
)
async for event in result.stream_events():
if event.type == "run_item_stream_event":
if event.name == "tool_called":
print(
f"-- Tool {event.item.raw_item.name} was called with args: {event.item.raw_item.arguments} "
)
elif event.name == "reasoning_item_created":
summary = event.item.raw_item.summary
# there’s at least one summary part
# o-series models will send this every response, it is sometimes blank
if summary:
text = summary[0].text
print(f"-- Reasoning item created: {text}")
print("--")
elif event.name == "message_output_created":
print(event.item.raw_item.content[0].text)
else:
pass # Ignore other event types |
Resolve: #252