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§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Human-readable description for the LLM.
Sourcefn input_schema(&self) -> Value
fn input_schema(&self) -> Value
JSON Schema for the tool’s input parameters.
Sourcefn execute(&self, input: Value) -> ToolResult<'_>
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".