pub trait Tool: Send + Sync {
// Required methods
fn spec(&self) -> &ToolSpec;
fn call<'life0, 'life1, 'async_trait>(
&'life0 self,
args: Value,
ctx: &'life1 ToolContext,
) -> Pin<Box<dyn Future<Output = Result<ToolOutput, ToolError>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait;
// Provided method
fn uses_network(&self) -> bool { ... }
}Expand description
A capability an agent can call: a spec the model sees and an async call.
Object safe, so registries hold Arc<dyn Tool>. Arguments arrive as JSON
already checked against spec().schema when called through a registry.
Required Methods§
Sourcefn call<'life0, 'life1, 'async_trait>(
&'life0 self,
args: Value,
ctx: &'life1 ToolContext,
) -> Pin<Box<dyn Future<Output = Result<ToolOutput, ToolError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn call<'life0, 'life1, 'async_trait>(
&'life0 self,
args: Value,
ctx: &'life1 ToolContext,
) -> Pin<Box<dyn Future<Output = Result<ToolOutput, ToolError>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Runs the tool with JSON args and the per-call ctx.
Returns the model-facing output or a ToolError.
Provided Methods§
Sourcefn uses_network(&self) -> bool
fn uses_network(&self) -> bool
Reports whether a call sends a request over the network, as
web_fetch, web_search, HTTP and hosted tools do. A private agent
refuses such a tool at build. Default false: override it when true.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".