Skip to main content

Tool

Trait Tool 

Source
pub trait Tool: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn description(&self) -> &str;
    fn parameters_schema(&self) -> Value;
    fn execute<'life0, 'life1, 'async_trait>(
        &'life0 self,
        args: Value,
        ctx: &'life1 mut AgentContext,
    ) -> Pin<Box<dyn Future<Output = Result<ToolOutput, ToolError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;

    // Provided methods
    fn is_system(&self) -> bool { ... }
    fn is_read_only(&self) -> bool { ... }
    fn execute_readonly<'life0, 'life1, 'async_trait>(
        &'life0 self,
        args: Value,
        _ctx: &'life1 AgentContext,
    ) -> Pin<Box<dyn Future<Output = Result<ToolOutput, ToolError>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait { ... }
    fn to_def(&self) -> ToolDef { ... }
}
Expand description

A tool that an agent can invoke.

Required Methods§

Source

fn name(&self) -> &str

Source

fn description(&self) -> &str

Source

fn parameters_schema(&self) -> Value

Source

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, args: Value, ctx: &'life1 mut AgentContext, ) -> Pin<Box<dyn Future<Output = Result<ToolOutput, ToolError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Provided Methods§

Source

fn is_system(&self) -> bool

Source

fn is_read_only(&self) -> bool

Source

fn execute_readonly<'life0, 'life1, 'async_trait>( &'life0 self, args: Value, _ctx: &'life1 AgentContext, ) -> Pin<Box<dyn Future<Output = Result<ToolOutput, ToolError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Source

fn to_def(&self) -> ToolDef

Implementors§