pub trait Tool: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn description(&self) -> &str;
fn parameters_schema(&self) -> Value;
fn execute(
&self,
input: &Value,
) -> impl Future<Output = Result<ToolOutput>> + Send;
// Provided method
fn retry_policy(&self) -> Option<ToolRetryPolicy> { ... }
}Expand description
Trait for tools the agent can invoke. Tools must have unique names and declare a JSON Schema for parameters.
Required Methods§
Sourcefn name(&self) -> &str
fn name(&self) -> &str
Unique identifier for the tool. Used by the model when requesting a call.
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Human-readable description. The model uses this to decide when to call the tool.
Sourcefn parameters_schema(&self) -> Value
fn parameters_schema(&self) -> Value
JSON Schema for the tool’s parameters. Validates and guides the model’s argument generation.
Provided Methods§
Sourcefn retry_policy(&self) -> Option<ToolRetryPolicy>
fn retry_policy(&self) -> Option<ToolRetryPolicy>
Per-tool retry policy. If Some, overrides the agent-level retry policy
for this tool. Return None to use the agent’s default.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".