Skip to main content

ToolCallInterceptor

Trait ToolCallInterceptor 

Source
pub trait ToolCallInterceptor: Send + Sync {
    // Required method
    fn intercept(&self, call: ToolCall) -> ToolCall;
}
Expand description

Hook that runs before each tool call inside super::ToolNode.

Can inspect and modify the ToolCall before execution. Return the (possibly modified) ToolCall to proceed.

§Example

struct LoggingInterceptor;

impl ToolCallInterceptor for LoggingInterceptor {
    fn intercept(&self, call: ToolCall) -> ToolCall {
        tracing::info!("Tool call: {} with {:?}", call.name, call.args);
        call
    }
}

Required Methods§

Source

fn intercept(&self, call: ToolCall) -> ToolCall

Called before tool execution. Return the (possibly modified) ToolCall.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§