pub trait ToolMiddleware: WasmCompatSend + WasmCompatSync {
// Required method
fn process<'a>(
&'a self,
call: &'a ToolCall,
ctx: &'a ToolContext,
next: Next<'a>,
) -> WasmBoxedFuture<'a, Result<ToolOutput, ToolError>>;
}Expand description
Middleware that wraps tool execution.
Each middleware receives the call, context, and a Next to continue the chain.
Middleware can:
- Inspect/modify the call before passing it on
- Short-circuit by returning without calling
next.run() - Inspect/modify the result after the tool executes
Uses boxed futures for dyn-compatibility (heterogeneous middleware collections).
Required Methods§
Sourcefn process<'a>(
&'a self,
call: &'a ToolCall,
ctx: &'a ToolContext,
next: Next<'a>,
) -> WasmBoxedFuture<'a, Result<ToolOutput, ToolError>>
fn process<'a>( &'a self, call: &'a ToolCall, ctx: &'a ToolContext, next: Next<'a>, ) -> WasmBoxedFuture<'a, Result<ToolOutput, ToolError>>
Process a tool call, optionally delegating to the next middleware/tool.