Execute Tool Call • AI Agent SDK
execute_tool_call: Execute a tool call with all hooks and middleware.
execute_tool_call
Method
</div>
This is a method of the MiddlewareManager class in the middleware module.
Execute a tool call with all hooks and middleware.
Order:
- before_tool hooks (in order)
- wrap_tool_call middleware chain
- actual tool call
- after_tool hooks (in reverse order)
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#8B0000', 'primaryTextColor': '#fff', 'primaryBorderColor': '#710101', 'lineColor': '#189AB4', 'secondaryColor': '#189AB4', 'tertiaryColor': '#fff' }}}%%
graph LR
agent["Agent"] -- "uses" --> tool["Tool: execute_tool_call"]
tool -- "returns" --> result["Result"]
style tool fill:#189AB4,color:#fff
style agent fill:#8B0000,color:#fff
style result fill:#8B0000,color:#fffSignature
def execute_tool_call(request: ToolRequest, tool_fn: Callable[[ToolRequest], ToolResponse]) -> ToolResponseParameters
ParamField
ToolRequestNo description available.
ParamField
CallableNo description available.
Returns
ResponseField
ToolResponseThe result of the operation.
Uses
tool_fnrun_before_toolrun_after_toolexecute
Source
View on GitHubpraisonaiagents/hooks/middleware.py at line 497