pub trait Tool:
Send
+ Sync
+ 'static {
type Input: Send + 'static;
type Output: Send + 'static;
const NAME: &'static str;
const DESCRIPTION: &'static str;
// Required method
fn call(
&self,
input: Self::Input,
ctx: &ToolContext,
) -> BoxFuture<'static, Result<Self::Output, ToolError>>;
}Expand description
Native-first Tool trait with NO serde bounds.
This trait defines a tool that can be called with native Rust types.
Serialization is handled separately by ToolCodec at protocol boundaries.
§Example
ⓘ
use agentic_tools_core::{Tool, ToolContext, ToolError};
use futures::future::BoxFuture;
struct GreetTool;
impl Tool for GreetTool {
type Input = String;
type Output = String;
const NAME: &'static str = "greet";
const DESCRIPTION: &'static str = "Greet someone by name";
fn call(&self, input: Self::Input, _ctx: &ToolContext)
-> BoxFuture<'static, Result<Self::Output, ToolError>>
{
Box::pin(async move {
Ok(format!("Hello, {}!", input))
})
}
}Required Associated Constants§
Sourceconst DESCRIPTION: &'static str
const DESCRIPTION: &'static str
Human-readable description of what the tool does.
Required Associated Types§
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.