Skip to main content

ToolExecutor

Trait ToolExecutor 

Source
pub trait ToolExecutor: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn schema(&self) -> ToolDefinition;
    fn execute<'life0, 'async_trait>(
        &'life0 self,
        args: Value,
        ctx: ExecContext,
    ) -> Pin<Box<dyn Future<Output = ToolOutcome> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn is_internal(&self) -> bool { ... }
}
Expand description

Implemented by every tool that the model can call. All tools are Send + Sync — they run across tokio select! branches inside the effect runner.

Required Methods§

Source

fn name(&self) -> &'static str

Canonical name the model uses to call this tool. Matches schema().name exactly.

Source

fn schema(&self) -> ToolDefinition

JSON-schema description the model sees in the outgoing request. Adapters translate this into provider-native shape (Anthropic’s type: "custom", Gemini’s function_declarations, OpenAI’s flat tools, Ollama’s function calling). The same ToolDefinition feeds all four.

Source

fn execute<'life0, 'async_trait>( &'life0 self, args: Value, ctx: ExecContext, ) -> Pin<Box<dyn Future<Output = ToolOutcome> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Run the tool. The returned ToolOutcome is passed verbatim into Msg::ToolFinished — there’s no error-to-outcome conversion happening outside this function.

Provided Methods§

Source

fn is_internal(&self) -> bool

True for tools that exist for internal dispatch only and should NOT be advertised to the model (e.g. the MCP proxy router, which fronts every mcp__server__tool call — the individual MCP tools are advertised separately from state.mcp.servers). Default false.

Implementors§