Wrap Tool Call • AI Agent SDK

wrap_tool_call: Decorator to mark a function as a wrap_tool_call middleware.

wrap_tool_call

Function

</div>

This function is defined in the middleware module.

Decorator to mark a function as a wrap_tool_call middleware.

The function receives (request, call_next) and should call call_next(request) to continue the chain, or return early to short-circuit.

Diagram

uses

returns

Agent

Tool: wrap_tool_call

Result

Signature

python
def wrap_tool_call(func: WrapToolCallFn) -> WrapToolCallFn

Parameters

ParamField WrapToolCallFn

No description available.

Returns

ResponseField WrapToolCallFn

The result of the operation.

Usage

python
@wrap_tool_call
    def retry_flaky_tool(request, call_next):
        last_error = None
        for _ in range(3):
            try:
                return call_next(request)
            except Exception as e:
                last_error = e
        raise last_error

Source

View on GitHub

praisonaiagents/hooks/middleware.py at line 279


Related Documentation