pub trait AgentTool: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn label(&self) -> &str;
fn description(&self) -> &str;
fn parameters_schema(&self) -> Value;
fn execute<'life0, 'async_trait>(
&'life0 self,
params: Value,
ctx: ToolContext,
) -> Pin<Box<dyn Future<Output = Result<ToolResult, ToolError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
A tool the agent can call. Implement this trait for your tools.
Required Methods§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Description for the LLM
Sourcefn parameters_schema(&self) -> Value
fn parameters_schema(&self) -> Value
JSON Schema for parameters
Sourcefn execute<'life0, 'async_trait>(
&'life0 self,
params: Value,
ctx: ToolContext,
) -> Pin<Box<dyn Future<Output = Result<ToolResult, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
params: Value,
ctx: ToolContext,
) -> Pin<Box<dyn Future<Output = Result<ToolResult, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute the tool.
The ctx parameter provides per-invocation context:
ctx.tool_call_id/ctx.tool_name— for correlation and loggingctx.cancel— cancellation token; checkis_cancelled()in long-running toolsctx.on_update— optional callback for streaming partialToolResults (UI/logging only)ctx.on_progress— optional callback for user-facing progress text (ProgressMessage)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
impl AgentTool for BashTool
impl AgentTool for EditFileTool
impl AgentTool for ListFilesTool
impl AgentTool for McpToolAdapter
impl AgentTool for OpenApiToolAdapter
Available on crate feature
openapi only.