Skip to main content

Tool

Trait Tool 

Source
pub trait Tool: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn label(&self) -> &str;
    fn description(&self) -> &str;
    fn parameters(&self) -> Value;
    fn is_readonly(&self) -> bool;
    fn execute<'life0, 'life1, 'async_trait>(
        &'life0 self,
        call_id: &'life1 str,
        params: Value,
        ctx: ToolContext,
    ) -> Pin<Box<dyn Future<Output = Result<ToolOutput>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

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

A tool that can be invoked by the agent.

Required Methods§

Source

fn name(&self) -> &str

Tool name (used in LLM tool calls).

Source

fn label(&self) -> &str

Human-readable label.

Source

fn description(&self) -> &str

Description shown to the LLM.

Source

fn parameters(&self) -> Value

JSON Schema for parameters.

Source

fn is_readonly(&self) -> bool

Whether this tool only reads (no side effects).

Source

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, call_id: &'life1 str, params: Value, ctx: ToolContext, ) -> Pin<Box<dyn Future<Output = Result<ToolOutput>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Execute the tool.

Provided Methods§

Source

fn policy_metadata(&self) -> ToolMetadata

Metadata used by the runtime reference monitor.

Implementors§