Skip to content

Enhance on_tool_start Hook to Include Tool Call Arguments #252

Open
@yanmxa

Description

@yanmxa

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:

  1. Improved Debugging & Tracing: Developers can log and analyze tool inputs before execution.
  2. Greater Flexibility: Hooks can validate or preprocess tool arguments before they are used.
  3. More Context for Hooks: Allows hooks to monitor execution flows with full tool call details.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions