Skip to main content

AgentTool

Trait AgentTool 

Source
pub trait AgentTool: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn description(&self) -> &str;
    fn parameters(&self) -> Value;
    fn execute<'life0, 'life1, 'async_trait>(
        &'life0 self,
        tool_call_id: &'life1 str,
        args: Value,
    ) -> Pin<Box<dyn Future<Output = Result<AgentToolResult, String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn label(&self) -> &str { ... }
    fn requires_permission(&self) -> bool { ... }
}
Expand description

Tool execution trait — analog of AgentTool.execute in TS.

Required Methods§

Source

fn name(&self) -> &str

Source

fn description(&self) -> &str

Source

fn parameters(&self) -> Value

Source

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, tool_call_id: &'life1 str, args: Value, ) -> Pin<Box<dyn Future<Output = Result<AgentToolResult, String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Provided Methods§

Source

fn label(&self) -> &str

Source

fn requires_permission(&self) -> bool

Whether the tool requires user permission by default. Read-only tools (read, ls, grep, glob) return false; mutating or side-effecting tools (bash, write, edit) return true.

Implementors§