Open
Description
Please read this first
- Have you read the docs?Agents SDK docs - Yes
- Have you searched for related issues? Others may have had similar requesrs - Yes
Describe the feature
Currently, the on_tool_start
hook in the Agents SDK only provides access to the Agent, Tool (definition), and context, but does not include the actual tool call arguments.
This limitation makes it difficult to trace and debug the agent's lifecycle, as there's no way to inspect the exact parameters passed to the tool before execution.
Proposed Enhancement:
Modify the on_tool_start
hook definition to include the tool call arguments, providing full visibility into the tool invocation process.
- Current Definition
async def on_tool_start(
self,
context: RunContextWrapper[TContext],
agent: Agent[TContext],
tool: Tool,
) -> None:
"""Called before a tool is invoked."""
pass
- Suggested Update
async def on_tool_start(
self,
context: RunContextWrapper[TContext],
agent: Agent[TContext],
action: Action, # Include the tool and the tool_call(arguments)
) -> None:
"""Called before a tool is invoked."""
pass
Why This Improvement Matters:
- Improved Debugging & Tracing: Developers can log and analyze tool inputs before execution.
- Greater Flexibility: Hooks can validate or preprocess tool arguments before they are used.
- More Context for Hooks: Allows hooks to monitor execution flows with full tool call details.
Activity
on_tool_start
hook #253MrJarnould commentedon Mar 25, 2025
Until the linked PR is accepted, is there any other way to obtain the tool call arguments using hooks before the agent calls the tool?
vanhtuan0409 commentedon Mar 25, 2025
Some workaround I think of is either using LLM tracing, put logging in tool implement or hijack the network call
yanmxa commentedon Mar 28, 2025
@MrJarnould @vanhtuan0409 Yes, I do it in the tool calling internal for now. But it's more reasonable to put this in the tracing hook :)
MrJarnould commentedon Mar 28, 2025
I hope your PR gets reviewed soon!
Kalai9976 commentedon Apr 17, 2025
Any idea when this enhancement will be released ?
yanmxa commentedon Apr 26, 2025
@rm-openai Could you please take a look at this issue? Thanks!
BarAshkenazi commentedon May 26, 2025
Very important. For now, I used the Runner.run_streamed to catch the tools calls, and I can get the args: