pub trait AgentTool: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn description(&self) -> &str;
fn input_schema(&self) -> Value;
fn execute<'life0, 'async_trait>(
&'life0 self,
args: Value,
cancel: CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<ToolResult>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn label(&self) -> &str { ... }
fn execution_mode(&self) -> ExecutionMode { ... }
fn prepare_arguments(&self, args: Value) -> Value { ... }
fn schema(&self) -> ToolSchema { ... }
}Expand description
A tool the agent can call. prepare_arguments lets a tool normalize raw
model arguments before validation (e.g. the edit tool accepting a legacy
oldText/newText shape).
Required Methods§
fn name(&self) -> &str
fn description(&self) -> &str
Sourcefn input_schema(&self) -> Value
fn input_schema(&self) -> Value
JSON Schema (object) describing the tool’s parameters.
Sourcefn execute<'life0, 'async_trait>(
&'life0 self,
args: Value,
cancel: CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<ToolResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn execute<'life0, 'async_trait>(
&'life0 self,
args: Value,
cancel: CancellationToken,
) -> Pin<Box<dyn Future<Output = Result<ToolResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Execute the tool. Throw on failure — the loop converts the error into an error tool result.
Provided Methods§
fn label(&self) -> &str
fn execution_mode(&self) -> ExecutionMode
fn prepare_arguments(&self, args: Value) -> Value
Sourcefn schema(&self) -> ToolSchema
fn schema(&self) -> ToolSchema
The schema fragment sent to the model.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".