Skip to main content

wrap_tool_call

Function
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.

Signature

def wrap_tool_call(func: WrapToolCallFn) -> WrapToolCallFn

Parameters

func
WrapToolCallFn
required
No description available.

Returns

Returns
WrapToolCallFn
The result of the operation.

Usage

@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