Skip to main content

Tool

Trait Tool 

Source
pub trait Tool: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn description(&self) -> &str;
    fn schema(&self) -> Value;
    fn risk(&self) -> RiskLevel;
    fn call<'life0, 'life1, 'async_trait>(
        &'life0 self,
        args: Value,
        ctx: &'life1 ToolCtx,
    ) -> Pin<Box<dyn Future<Output = Result<ToolResult>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn metadata(&self) -> ToolMetadata { ... }
}
Expand description

What an agent can do. Every tool declares a JSON schema and a risk level used by the autonomy gate.

Required Methods§

Source

fn name(&self) -> &str

Source

fn description(&self) -> &str

Source

fn schema(&self) -> Value

Source

fn risk(&self) -> RiskLevel

Source

fn call<'life0, 'life1, 'async_trait>( &'life0 self, args: Value, ctx: &'life1 ToolCtx, ) -> Pin<Box<dyn Future<Output = Result<ToolResult>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Provided Methods§

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§