awrap_tool_call(
self,
request: ToolCallRequest,
handler: Callable[[ToolCallRequest], Awaitable[ToolMessage | Name | Type | Description |
|---|---|---|
request* | ToolCallRequest | Tool call request with call Access state via |
handler* | Callable[[ToolCallRequest], Awaitable[ToolMessage | Command[Any]]] |
Intercept and control async tool execution via handler callback.
The handler callback executes the tool call and returns a ToolMessage or
Command. Middleware can call the handler multiple times for retry logic, skip
calling it to short-circuit, or modify the request/response. Multiple middleware
compose with first in list as outermost layer.
The handler Callable can be invoked multiple times for retry logic.
Each call to handler is independent and stateless.
Async callable to execute the tool and returns ToolMessage or
Command.
Call this to execute the tool.
Can be called multiple times for retry logic.
Can skip calling it to short-circuit.