pub trait Tool: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn description(&self) -> &str;
fn parameters(&self) -> Value;
fn output_schema(&self) -> Value;
fn call<'life0, 'async_trait>(
&'life0 self,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn implementation_version(&self) -> &str { ... }
fn meta(&self) -> ToolMeta { ... }
fn call_with_context<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ToolExecutionContext,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
A callable tool. parameters is a JSON-Schema object describing the args.
Required Methods§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Model-facing description.
Sourcefn parameters(&self) -> Value
fn parameters(&self) -> Value
JSON Schema for the arguments.
Sourcefn output_schema(&self) -> Value
fn output_schema(&self) -> Value
JSON Schema for the result.
Sourcefn call<'life0, 'async_trait>(
&'life0 self,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn call<'life0, 'async_trait>(
&'life0 self,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Run the tool. On success return a JSON value; on failure return a short
error string (surfaced back to the model as {"error": ...} so it can
recover) — mirrors the Python “success → dict / failure → {error}” rule.
Provided Methods§
Sourcefn implementation_version(&self) -> &str
fn implementation_version(&self) -> &str
Implementation version pinned by Profile revisions.
Sourcefn call_with_context<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ToolExecutionContext,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn call_with_context<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 ToolExecutionContext,
args: Value,
) -> Pin<Box<dyn Future<Output = Result<Value, String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Like call with the execution context; the default ignores the context.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".