pub trait Tool: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn label(&self) -> &str;
fn description(&self) -> &str;
fn parameters(&self) -> Value;
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
tool_call_id: &'life1 str,
input: Value,
on_update: Option<Box<dyn Fn(ToolUpdate) + Send + Sync>>,
) -> Pin<Box<dyn Future<Output = Result<ToolOutput>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided method
fn is_read_only(&self) -> bool { ... }
}Expand description
A tool that can be executed by the agent.
Required Methods§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Get the tool description.
Sourcefn parameters(&self) -> Value
fn parameters(&self) -> Value
Get the tool parameters as JSON Schema.
Sourcefn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
tool_call_id: &'life1 str,
input: Value,
on_update: Option<Box<dyn Fn(ToolUpdate) + Send + Sync>>,
) -> Pin<Box<dyn Future<Output = Result<ToolOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
tool_call_id: &'life1 str,
input: Value,
on_update: Option<Box<dyn Fn(ToolUpdate) + Send + Sync>>,
) -> Pin<Box<dyn Future<Output = Result<ToolOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execute the tool.
Tools may call on_update to stream incremental results (e.g. while a long-running bash
command is still producing output). The final return value is a ToolOutput which is
persisted into the session as a tool result message.
Provided Methods§
Sourcefn is_read_only(&self) -> bool
fn is_read_only(&self) -> bool
Whether the tool is read-only and safe to execute in parallel with other read-only tools.
Defaults to false (safe/sequential).