After Tool • AI Agent SDK
after_tool: Decorator to mark a function as an after_tool hook.
after_tool
Function
</div>
This function is defined in the middleware module.
Decorator to mark a function as an after_tool hook.
The function receives a ToolResponse and should return a (possibly modified) ToolResponse.
%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#8B0000', 'primaryTextColor': '#fff', 'primaryBorderColor': '#710101', 'lineColor': '#189AB4', 'secondaryColor': '#189AB4', 'tertiaryColor': '#fff' }}}%%
graph LR
agent["Agent"] -- "uses" --> tool["Tool: after_tool"]
tool -- "returns" --> result["Result"]
style tool fill:#189AB4,color:#fff
style agent fill:#8B0000,color:#fff
style result fill:#8B0000,color:#fffSignature
def after_tool(func: AfterToolFn) -> AfterToolFnParameters
ParamField
AfterToolFnNo description available.
Returns
ResponseField
AfterToolFnThe result of the operation.
Usage
@after_tool
def log_result(response):
print(f"Tool {response.tool_name} returned: {response.result}")
return responseSource
View on GitHubpraisonaiagents/hooks/middleware.py at line 264