Skip to main content

Tool

Trait Tool 

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 methods
    fn output_schema(&self) -> Option<Value> { ... }
    fn param_domains(&self) -> Vec<(&'static str, OptionDomain)> { ... }
    fn spec(&self) -> ToolSpec { ... }
}

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 output_schema(&self) -> Option<Value>

JSON schema describing the structured output this tool attaches to ToolOutput::data, when it declares one. None means the tool emits display text only; authoring surfaces fall back to sample-derived shapes from captured runs.

Source

fn param_domains(&self) -> Vec<(&'static str, OptionDomain)>

Option domains for parameters whose value sets live in runtime config rather than the static schema (channel refs, peer targets, …). Surfaces resolve these through the runtime to render real selectable choices. Default: no domain-typed parameters.

Source

fn spec(&self) -> ToolSpec

Implementors§