Skip to content
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

Enhance on_tool_start Hook to Include Tool Call Arguments #252

Open
yanmxa opened this issue Mar 20, 2025 · 0 comments · May be fixed by #253
Open

Enhance on_tool_start Hook to Include Tool Call Arguments #252

yanmxa opened this issue Mar 20, 2025 · 0 comments · May be fixed by #253
Labels
enhancement New feature or request

Comments

@yanmxa
Copy link

yanmxa commented Mar 20, 2025

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],
    tool: Tool,
    arguments: str,  # Include the actual 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.
@yanmxa yanmxa added the enhancement New feature or request label Mar 20, 2025
@yanmxa yanmxa linked a pull request Mar 20, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant