Skip to main content

Tool

Trait Tool 

Source
pub trait Tool: Send + Sync {
    // Required methods
    fn name(&self) -> &str;
    fn description(&self) -> &str;
    fn input_schema(&self) -> Value;
    fn execute(&self, input: Value) -> ToolResult<'_>;
}
Expand description

A tool that can be invoked by an LLM.

Tools are contributed by plugins via Plugin::tools() and registered with the host’s tool registry. The LLM calls tools by name.

§Object Safety

This trait is object-safe and designed for use as Box<dyn Tool>.

Required Methods§

Source

fn name(&self) -> &str

Tool name — must match what the LLM calls.

Source

fn description(&self) -> &str

Human-readable description for the LLM.

Source

fn input_schema(&self) -> Value

JSON Schema for the tool’s input parameters.

Source

fn execute(&self, input: Value) -> ToolResult<'_>

Execute the tool with the given input.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§