As Tool Call Hook • AI Agent SDK

as_tool_call_hook: Adapt a plain “on_tool_call“ callback into a “before_tool“ hook.

as_tool_call_hook

Function

</div>

This function is defined in the middleware module.

Adapt a plain `on_tool_call callback into a before_tool` hook.

`HooksConfig(on_tool_call=...) is routed onto the existing before_tool middleware slot, so it fires for every tool the agent executes (sync and async paths both run through :class:MiddlewareManager). The callback receives the :class:ToolRequest`; its return value is ignored so the request passes through unchanged.

Diagram

uses

returns

Agent

Tool: as_tool_call_hook

Result

Signature

python
def as_tool_call_hook(callback: Callable[[Any], Any]) -> BeforeToolFn

Parameters

ParamField Callable

No description available.

Returns

ResponseField BeforeToolFn

The result of the operation.

Source

View on GitHub

praisonaiagents/hooks/middleware.py at line 358


Related Documentation