pub trait BaseTool: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn description(&self) -> &str;
fn run<'life0, 'async_trait>(
&'life0 self,
input: String,
) -> Pin<Box<dyn Future<Output = Result<String, ToolError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn args_schema(&self) -> Option<Value> { ... }
fn return_direct(&self) -> bool { ... }
fn handle_error<'life0, 'async_trait>(
&'life0 self,
error: ToolError,
) -> Pin<Box<dyn Future<Output = String> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
}Expand description
Base tool trait (object-safe version).
This is the base interface for tool registries and Agents. Uses string input/output to simplify LLM calls.
All tools must implement this interface to be used by Agents.
Required Methods§
Sourcefn name(&self) -> &str
fn name(&self) -> &str
Returns the tool name.
Name should be unique and clearly express the tool’s purpose.
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Returns the tool description.
Description should detail the tool’s purpose, input format, and output format.
Provided Methods§
Sourcefn args_schema(&self) -> Option<Value>
fn args_schema(&self) -> Option<Value>
Returns the input JSON Schema.
Used to describe the tool’s input format to the LLM.
Sourcefn return_direct(&self) -> bool
fn return_direct(&self) -> bool
Whether to return result directly to user.
If true, tool output is returned directly to user, not passed to Agent.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".