Skip to main content

ToolExecutor

Trait ToolExecutor 

Source
pub trait ToolExecutor: Send + Sync {
    // Required method
    fn execute(
        &self,
        response: &str,
    ) -> impl Future<Output = Result<Option<ToolOutput>, ToolError>> + Send;

    // Provided methods
    fn execute_confirmed(
        &self,
        response: &str,
    ) -> impl Future<Output = Result<Option<ToolOutput>, ToolError>> + Send { ... }
    fn tool_definitions(&self) -> Vec<ToolDef> { ... }
    fn execute_tool_call(
        &self,
        _call: &ToolCall,
    ) -> impl Future<Output = Result<Option<ToolOutput>, ToolError>> + Send { ... }
    fn set_skill_env(&self, _env: Option<HashMap<String, String>>) { ... }
}
Expand description

Async trait for tool execution backends (shell, future MCP, A2A).

Accepts the full LLM response and returns an optional output. Returns None when no tool invocation is detected in the response.

Required Methods§

Source

fn execute( &self, response: &str, ) -> impl Future<Output = Result<Option<ToolOutput>, ToolError>> + Send

Provided Methods§

Source

fn execute_confirmed( &self, response: &str, ) -> impl Future<Output = Result<Option<ToolOutput>, ToolError>> + Send

Execute bypassing confirmation checks (called after user approves). Default: delegates to execute.

Source

fn tool_definitions(&self) -> Vec<ToolDef>

Return tool definitions this executor can handle.

Source

fn execute_tool_call( &self, _call: &ToolCall, ) -> impl Future<Output = Result<Option<ToolOutput>, ToolError>> + Send

Execute a structured tool call. Returns None if tool_id is not handled.

Source

fn set_skill_env(&self, _env: Option<HashMap<String, String>>)

Inject environment variables for the currently active skill. No-op by default.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§