Skip to main content

Tool

Trait Tool 

Source
pub trait Tool:
    Send
    + Sync
    + 'static {
    // Required methods
    fn name(&self) -> &str;
    fn description(&self) -> &str;
    fn spec(&self) -> ToolSpec;
    fn input_schema(&self, style: PathStyle) -> Value;
    fn call<'life0, 'async_trait>(
        &'life0 self,
        i: Value,
        c: ToolContext,
        p: ProgressSender,
    ) -> Pin<Box<dyn Future<Output = Result<ToolResult, ToolError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn guide<'life0, 'life1, 'async_trait>(
        &'life0 self,
        _ctx: &'life1 PromptContext,
    ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait { ... }
    fn call_traits(&self, _input: &Value) -> CallTraits { ... }
    fn permission_facts<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _: &'life1 Value,
        _: &'life2 ToolContext,
    ) -> Pin<Box<dyn Future<Output = PermissionFacts> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
    fn validate_input<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 self,
        _: &'life1 Value,
        _: &'life2 ToolContext,
    ) -> Pin<Box<dyn Future<Output = ValidationResult> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait { ... }
}
Expand description

A tool the model can call.

What holds for every call is one spec; what depends on the call’s input is call_traits, which defaults to the spec’s answer. permission_facts is what the permission engine weighs about the call; a tool that states none is asked about.

Required Methods§

Source

fn name(&self) -> &str

Source

fn description(&self) -> &str

Source

fn spec(&self) -> ToolSpec

Everything about this tool that holds for every call — see ToolSpec.

Source

fn input_schema(&self, style: PathStyle) -> Value

The input schema as worded for a session’s PathStyle; only tools whose argument docs mention paths read style.

Source

fn call<'life0, 'async_trait>( &'life0 self, i: Value, c: ToolContext, p: ProgressSender, ) -> Pin<Box<dyn Future<Output = Result<ToolResult, ToolError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Provided Methods§

Source

fn guide<'life0, 'life1, 'async_trait>( &'life0 self, _ctx: &'life1 PromptContext, ) -> Pin<Box<dyn Future<Output = Option<String>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

This tool’s detailed usage guide, when it has one that says more than description() already does.

ToolDefs carry only description(); the full guides total ~85 KB across the built-in set, too much to pay on every API call, so the model fetches them on demand via ToolSearch{query: "select:<name>"}.

Source

fn call_traits(&self, _input: &Value) -> CallTraits

What this call reads, writes and may run beside; spec().traits unless the answer depends on the input.

Source

fn permission_facts<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _: &'life1 Value, _: &'life2 ToolContext, ) -> Pin<Box<dyn Future<Output = PermissionFacts> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source

fn validate_input<'life0, 'life1, 'life2, 'async_trait>( &'life0 self, _: &'life1 Value, _: &'life2 ToolContext, ) -> Pin<Box<dyn Future<Output = ValidationResult> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§