Skip to main content

Tool

Trait Tool 

Source
pub trait Tool: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn schema(&self) -> ToolSchema;
    fn execute<'life0, 'life1, 'async_trait>(
        &'life0 self,
        args: ToolArgs,
        ctx: &'life1 mut ExecContext,
    ) -> Pin<Box<dyn Future<Output = ExecResult> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided method
    fn validate(&self, args: &ToolArgs) -> Vec<ValidationIssue> { ... }
}
Expand description

A tool that can be executed.

Required Methods§

Source

fn name(&self) -> &str

The tool’s name (used for lookup).

Source

fn schema(&self) -> ToolSchema

Get the tool’s schema.

Source

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, args: ToolArgs, ctx: &'life1 mut ExecContext, ) -> Pin<Box<dyn Future<Output = ExecResult> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Execute the tool with the given arguments and context.

Provided Methods§

Source

fn validate(&self, args: &ToolArgs) -> Vec<ValidationIssue>

Validate arguments without executing.

Default implementation validates against the schema. Override this for semantic checks (regex validity, zero increment, etc.).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§