Skip to main content

Tool

Trait Tool 

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

    // Provided method
    fn spec(&self) -> ToolSpec { ... }
}
Expand description

Core tool trait — implement for any capability.

Every Tool is Attributable: log emissions and audit traces from a tool call carry the same <kind>.<alias> composite the rest of the runtime uses for channels, providers, and memory. The supertrait bound makes &dyn Tool coerce to &dyn Attributable automatically, so dispatch-site logging can attribute without knowing the concrete tool type.

Required Methods§

Source

fn name(&self) -> &str

Tool name (used in LLM function calling)

Source

fn description(&self) -> &str

Human-readable description

Source

fn parameters_schema(&self) -> Value

JSON schema for parameters

Source

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

Execute the tool with given arguments

Provided Methods§

Source

fn spec(&self) -> ToolSpec

Get the full spec for LLM registration

Implementors§