Skip to main content

ToolExecutor

Trait ToolExecutor 

Source
pub trait ToolExecutor: Send {
    // Required method
    fn execute<'life0, 'life1, 'life2, 'life3, 'async_trait>(
        &'life0 mut self,
        tool_call: &'life1 ToolCall,
        output_tx: &'life2 Sender<String>,
        cancel: &'life3 CancelToken,
    ) -> Pin<Box<dyn Future<Output = Result<ToolResultMessage>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             'life3: 'async_trait;
}
Expand description

Trait for tool execution (allows plugin-based or in-process).

Required Methods§

Source

fn execute<'life0, 'life1, 'life2, 'life3, 'async_trait>( &'life0 mut self, tool_call: &'life1 ToolCall, output_tx: &'life2 Sender<String>, cancel: &'life3 CancelToken, ) -> Pin<Box<dyn Future<Output = Result<ToolResultMessage>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, 'life3: 'async_trait,

Execute a tool call.

cancel is a shared cancellation flag. Long-running tools (bash) poll it and abort mid-execution when it becomes true; short tools (read, write, edit) may ignore it or check it once at the top.

Implementations that cannot poll the flag directly (e.g. a plugin subprocess over an RPC channel) should spawn a background watcher that translates the flag into a [PluginRequest::CancelToolCall] sent to the plugin.

Implementors§