Skip to main content

Tool

Trait Tool 

Source
pub trait Tool: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn description(&self) -> &str;
    fn parameters(&self) -> Value;
    fn execute<'a>(
        &'a self,
        args: Value,
        ctx: &'a ToolContext,
    ) -> ToolFuture<'a>;

    // Provided methods
    fn definition(&self) -> ToolDefinition { ... }
    fn is_allowed(&self, permissions: &PermissionSet) -> bool { ... }
}
Expand description

A tool that can be invoked by the LLM

Required Methods§

Source

fn name(&self) -> &str

Name of the tool

Source

fn description(&self) -> &str

Description for the LLM

Source

fn parameters(&self) -> Value

JSON Schema for the tool parameters

Source

fn execute<'a>(&'a self, args: Value, ctx: &'a ToolContext) -> ToolFuture<'a>

Execute the tool

Provided Methods§

Source

fn definition(&self) -> ToolDefinition

Get the full tool definition for LLM requests

Source

fn is_allowed(&self, permissions: &PermissionSet) -> bool

Whether this tool is allowed given a permission set.

Resolution: rules (allow/ask/deny), then legacy allowed/denied lists and category flags. Ask still returns true so the tool appears in the schema; the agent loop prompts before execution.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§