pub trait Tool: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn description(&self) -> &str;
fn parameters(&self) -> Value;
fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
args: &'life1 Value,
ctx: &'life2 ToolContext,
) -> Pin<Box<dyn Future<Output = Result<ToolOutput>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
}Expand description
Tool trait - the core abstraction for all tools
Implement this trait to create custom tools that can be registered with the ToolRegistry.
Required Methods§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Human-readable description for LLM
Sourcefn parameters(&self) -> Value
fn parameters(&self) -> Value
JSON Schema for tool parameters
Sourcefn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
args: &'life1 Value,
ctx: &'life2 ToolContext,
) -> Pin<Box<dyn Future<Output = Result<ToolOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn execute<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
args: &'life1 Value,
ctx: &'life2 ToolContext,
) -> Pin<Box<dyn Future<Output = Result<ToolOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Execute the tool with given arguments