Skip to main content

Tool

Trait Tool 

Source
pub trait Tool: Send + Sync {
    // Required methods
    fn schema(&self) -> ToolSchema;
    fn invoke<'life0, 'async_trait>(
        &'life0 self,
        args: Value,
    ) -> Pin<Box<dyn Future<Output = Result<Value, KernelError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn name(&self) -> ToolName { ... }
}
Expand description

A composable, side-effectful capability.

Implementations MUST be cheap to clone (typically Arc-wrapped state) so the same tool instance can be referenced from multiple agents’ super::registry::ToolRegistry slices.

Required Methods§

Source

fn schema(&self) -> ToolSchema

Return this tool’s JSON-Schema-compatible contract.

Source

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

Invoke the tool with JSON arguments.

Provided Methods§

Source

fn name(&self) -> ToolName

Return this tool’s registry name.

Implementors§