Skip to main content

StaticToolExecute

Trait StaticToolExecute 

Source
pub trait StaticToolExecute:
    Send
    + Sync
    + 'static {
    // Required method
    fn execute<'life0, 'life1, 'async_trait>(
        &'life0 self,
        call: ToolCall<'life1>,
    ) -> Pin<Box<dyn Future<Output = ToolResult> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;

    // Provided method
    fn prepare_tool_call<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        tool_id: &'life1 ToolId,
        pending: PendingToolCall,
        _context: &'life2 ToolPrepareContext,
    ) -> Pin<Box<dyn Future<Output = Result<PreparedToolCall, ToolResult>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait,
             Self: 'async_trait { ... }
}
Expand description

Author a fixed-tool provider without hand-rolling tool_manifests / resolve_contract: supply the ToolDefinitions once and an StaticToolExecute for behavior. Per-call execution behavior for a StaticToolProvider.

Implement this on the struct that owns the tool’s runtime state (HTTP clients, shared mutable state, configuration flags, …). The provider’s manifests and contracts come from the ToolDefinitions passed to StaticToolProvider::new; this trait supplies only the dynamic behavior.

Required Methods§

Source

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, call: ToolCall<'life1>, ) -> Pin<Box<dyn Future<Output = ToolResult> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Execute a resolved tool call. Dispatch on call.name when serving more than one tool.

Provided Methods§

Source

fn prepare_tool_call<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, tool_id: &'life1 ToolId, pending: PendingToolCall, _context: &'life2 ToolPrepareContext, ) -> Pin<Box<dyn Future<Output = Result<PreparedToolCall, ToolResult>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait, Self: 'async_trait,

Optional argument-preparation hook, mirroring ToolProvider::prepare_tool_call. Defaults to the identity transform.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§