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.

Diagram

uses

returns

Agent

Tool: after_tool

Result

Signature

python
def after_tool(func: AfterToolFn) -> AfterToolFn

Parameters

ParamField AfterToolFn

No description available.

Returns

ResponseField AfterToolFn

The result of the operation.

Usage

python
@after_tool
    def log_result(response):
        print(f"Tool {response.tool_name} returned: {response.result}")
        return response

Source

View on GitHub

praisonaiagents/hooks/middleware.py at line 264


Related Documentation