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.