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§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Description for the LLM
Sourcefn parameters(&self) -> Value
fn parameters(&self) -> Value
JSON Schema for the tool parameters
Sourcefn execute<'a>(&'a self, args: Value, ctx: &'a ToolContext) -> ToolFuture<'a>
fn execute<'a>(&'a self, args: Value, ctx: &'a ToolContext) -> ToolFuture<'a>
Execute the tool
Provided Methods§
Sourcefn definition(&self) -> ToolDefinition
fn definition(&self) -> ToolDefinition
Get the full tool definition for LLM requests
Sourcefn is_allowed(&self, permissions: &PermissionSet) -> bool
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".