pub trait Tool: Send + Sync {
Show 13 methods
// Required methods
fn name(&self) -> &str;
fn description(&self) -> &str;
fn parameters_schema(&self) -> Value;
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 dyn ToolContext,
args: Value,
) -> Pin<Box<dyn Future<Output = ToolResult<ToolOutput>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn response_schema(&self) -> Option<Value> { ... }
fn is_read_only(&self) -> bool { ... }
fn is_concurrency_safe(&self) -> bool { ... }
fn is_long_running(&self) -> bool { ... }
fn side_effects(&self) -> SideEffects { ... }
fn requires_approval(&self) -> bool { ... }
fn approval_reason(&self) -> Option<String> { ... }
fn required_scopes(&self) -> &[&str] { ... }
fn to_spec(&self) -> ToolSpec { ... }
}Expand description
An executable tool that can be called by an LLM.
Required Methods§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Returns a human-readable description of the tool.
Sourcefn parameters_schema(&self) -> Value
fn parameters_schema(&self) -> Value
Returns the JSON Schema for the tool’s parameters.
Sourcefn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 dyn ToolContext,
args: Value,
) -> Pin<Box<dyn Future<Output = ToolResult<ToolOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: &'life1 dyn ToolContext,
args: Value,
) -> Pin<Box<dyn Future<Output = ToolResult<ToolOutput>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Executes the tool with the given context and arguments.
Provided Methods§
Sourcefn response_schema(&self) -> Option<Value>
fn response_schema(&self) -> Option<Value>
Returns the JSON Schema for the tool’s response (if any).
Sourcefn is_read_only(&self) -> bool
fn is_read_only(&self) -> bool
Returns true if the tool is read-only (no side effects).
Sourcefn is_concurrency_safe(&self) -> bool
fn is_concurrency_safe(&self) -> bool
Returns true if the tool is safe to run concurrently.
Sourcefn is_long_running(&self) -> bool
fn is_long_running(&self) -> bool
Returns true if the tool is expected to run for a long time.
Sourcefn side_effects(&self) -> SideEffects
fn side_effects(&self) -> SideEffects
Returns the side effects the tool may produce.
Sourcefn requires_approval(&self) -> bool
fn requires_approval(&self) -> bool
Returns true if the tool requires human approval before execution.
Sourcefn approval_reason(&self) -> Option<String>
fn approval_reason(&self) -> Option<String>
Returns the reason approval is needed, if applicable.
Sourcefn required_scopes(&self) -> &[&str]
fn required_scopes(&self) -> &[&str]
Returns the scopes required to use this tool.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".