pub trait BaseTool: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn invoke(
&self,
args: &JsonValue,
config: &RunnableConfig,
) -> Result<JsonValue, ToolError>;
// Provided methods
fn description(&self) -> &str { ... }
fn parameters(&self) -> Option<&JsonValue> { ... }
fn ainvoke<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
args: &'life1 JsonValue,
config: &'life2 RunnableConfig,
) -> Pin<Box<dyn Future<Output = Result<JsonValue, ToolError>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait { ... }
fn to_tool_def(&self) -> ToolDef { ... }
}Expand description
A tool that can be invoked by an agent.
Mirrors langchain-core’s BaseTool.
Required Methods§
Provided Methods§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
A description of what the tool does.
Sourcefn parameters(&self) -> Option<&JsonValue>
fn parameters(&self) -> Option<&JsonValue>
The JSON schema for the tool’s parameters.
Sourcefn ainvoke<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
args: &'life1 JsonValue,
config: &'life2 RunnableConfig,
) -> Pin<Box<dyn Future<Output = Result<JsonValue, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn ainvoke<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
args: &'life1 JsonValue,
config: &'life2 RunnableConfig,
) -> Pin<Box<dyn Future<Output = Result<JsonValue, ToolError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Invoke the tool asynchronously. Default delegates to sync invoke via block_in_place.
Sets up thread-local config/runtime context so that get_config() and
get_runtime() work inside sync tool code (needed by interrupt()).
Sourcefn to_tool_def(&self) -> ToolDef
fn to_tool_def(&self) -> ToolDef
Get the tool’s schema as a ToolCall-compatible descriptor.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".