Skip to main content

Tool

Trait Tool 

Source
pub trait Tool: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn definition(&self) -> ToolDefinition;
    fn execute<'life0, 'async_trait>(
        &'life0 self,
        input: Value,
    ) -> Pin<Box<dyn Future<Output = ToolResult> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn required_capability(&self) -> Capability;

    // Provided method
    fn timeout(&self) -> Duration { ... }
}
Expand description

Executable tool with capability enforcement.

Required Methods§

Source

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

Tool name (must match ToolDefinition name).

Source

fn definition(&self) -> ToolDefinition

JSON Schema definition for the LLM.

Source

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

Execute the tool with JSON input.

Source

fn required_capability(&self) -> Capability

Required capability to invoke this tool (Poka-Yoke).

Provided Methods§

Source

fn timeout(&self) -> Duration

Execution timeout (Jidoka: stop on timeout).

Implementors§