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 execute_tool_call_confirmed(
&self,
call: &ToolCall,
) -> impl Future<Output = Result<Option<ToolOutput>, ToolError>> + Send { ... }
fn set_skill_env(&self, _env: Option<HashMap<String, String>>) { ... }
fn set_effective_trust(&self, _level: TrustLevel) { ... }
fn is_tool_retryable(&self, _tool_id: &str) -> bool { ... }
}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§
fn execute( &self, response: &str, ) -> impl Future<Output = Result<Option<ToolOutput>, ToolError>> + Send
Provided Methods§
Sourcefn execute_confirmed(
&self,
response: &str,
) -> impl Future<Output = Result<Option<ToolOutput>, ToolError>> + Send
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.
Sourcefn tool_definitions(&self) -> Vec<ToolDef>
fn tool_definitions(&self) -> Vec<ToolDef>
Return tool definitions this executor can handle.
Sourcefn execute_tool_call(
&self,
_call: &ToolCall,
) -> impl Future<Output = Result<Option<ToolOutput>, ToolError>> + Send
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.
Sourcefn execute_tool_call_confirmed(
&self,
call: &ToolCall,
) -> impl Future<Output = Result<Option<ToolOutput>, ToolError>> + Send
fn execute_tool_call_confirmed( &self, call: &ToolCall, ) -> impl Future<Output = Result<Option<ToolOutput>, ToolError>> + Send
Execute a structured tool call bypassing confirmation checks.
Called after the user has explicitly approved the tool invocation.
Default implementation delegates to execute_tool_call.
Sourcefn set_skill_env(&self, _env: Option<HashMap<String, String>>)
fn set_skill_env(&self, _env: Option<HashMap<String, String>>)
Inject environment variables for the currently active skill. No-op by default.
Sourcefn set_effective_trust(&self, _level: TrustLevel)
fn set_effective_trust(&self, _level: TrustLevel)
Set the effective trust level for the currently active skill. No-op by default.
Sourcefn is_tool_retryable(&self, _tool_id: &str) -> bool
fn is_tool_retryable(&self, _tool_id: &str) -> bool
Whether the executor can safely retry this tool call on a transient error.
Only idempotent operations (e.g. read-only HTTP GET) should return true.
Shell commands and other non-idempotent operations must keep the default false
to prevent double-execution of side-effectful commands.
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.