wrap_tool_call(
func: _CallableReturningToolResponse | None = None,
*,
state_schema: type[StateT] | None| Name | Type | Description |
|---|---|---|
func | _CallableReturningToolResponse | None | Default: NoneFunction accepting (request, handler) that calls
handler(request) to execute the tool and returns final Can be sync or async. |
state_schema | type[StateT] | None | Default: NoneOptional custom state schema type. If not provided, uses the default |
tools | list[BaseTool] | None | Default: None |
name | str | None | Default: None |
Create middleware with wrap_tool_call hook from a function.
Async version is awrap_tool_call.
Converts a function with handler callback into middleware that can intercept tool calls, implement retry logic, monitor execution, and modify responses.
Additional tools to register with this middleware.
Middleware class name.
Defaults to function name.