pub trait ToolExecutor: Send + Sync {
// Required method
fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
name: &'life1 str,
args_json: &'life2 str,
) -> Pin<Box<dyn Future<Output = String> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
// Provided methods
fn specs(&self) -> Vec<ToolSpec> { ... }
fn owns(&self, name: &str) -> bool { ... }
fn needs_approval(&self, _name: &str) -> bool { ... }
}Expand description
Executes a tool call by name, returning a JSON result string. Also advertises the tools it can execute so the provider knows what’s callable.
Required Methods§
Sourcefn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
name: &'life1 str,
args_json: &'life2 str,
) -> Pin<Box<dyn Future<Output = String> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
name: &'life1 str,
args_json: &'life2 str,
) -> Pin<Box<dyn Future<Output = String> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Run name with JSON args_json; return a JSON result.
Provided Methods§
Sourcefn specs(&self) -> Vec<ToolSpec>
fn specs(&self) -> Vec<ToolSpec>
Specs for the tools this executor knows how to run. The default
returns an empty list — the model won’t be told about any tools, so it
won’t emit tool_calls. Real registries override this.
Sourcefn owns(&self, name: &str) -> bool
fn owns(&self, name: &str) -> bool
Whether this executor advertises a tool named name.
Used by composite/registry executors to route a call to its owning
source without materialising every source’s full Self::specs on the
hot path. The default derives the answer from Self::specs; executors
that cache or compute specs lazily should override with a cheaper check
(e.g. a name lookup that avoids cloning the spec list).
Sourcefn needs_approval(&self, _name: &str) -> bool
fn needs_approval(&self, _name: &str) -> bool
Whether name requires explicit human approval before Self::execute
may run. The default is false — pure / read-only tools shouldn’t
trigger an approval gate. Override for sensitive tools (writes, code
execution, network reach, anything with side effects).
When this returns true, run_turn does NOT call Self::execute.
Instead it surfaces the unexecuted tool calls via
TurnResult::pending_approvals; the caller is responsible for
persisting an approval_request event, waiting for a (cryptographically
signed) approval_response, and re-driving the loop on the next turn.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".