pub trait TypedTool: Send + Sync {
type Args: DeserializeOwned + JsonSchema;
type Output: Serialize;
// Required methods
fn name(&self) -> &'static str;
fn description(&self) -> &'static str;
fn call_typed<'life0, 'life1, 'async_trait>(
&'life0 self,
args: Self::Args,
ctx: &'life1 ToolContext,
) -> Pin<Box<dyn Future<Output = AgentResult<Self::Output>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn format_output(&self, output: Self::Output) -> Content { ... }
fn origin(&self) -> &'static str { ... }
fn version(&self) -> &'static str { ... }
fn exposure(&self) -> ToolExposure { ... }
fn should_activate(&self, _ctx: &ActivationContext) -> bool { ... }
}Required Associated Types§
type Args: DeserializeOwned + JsonSchema
type Output: Serialize
Required Methods§
fn name(&self) -> &'static str
fn description(&self) -> &'static str
fn call_typed<'life0, 'life1, 'async_trait>(
&'life0 self,
args: Self::Args,
ctx: &'life1 ToolContext,
) -> Pin<Box<dyn Future<Output = AgentResult<Self::Output>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Provided Methods§
fn format_output(&self, output: Self::Output) -> Content
Sourcefn origin(&self) -> &'static str
fn origin(&self) -> &'static str
Machine-readable origin of this tool (crate name, "agent-base", or "custom").
Sourcefn version(&self) -> &'static str
fn version(&self) -> &'static str
Crate/package version, or "unknown" when built outside a crate.
Sourcefn exposure(&self) -> ToolExposure
fn exposure(&self) -> ToolExposure
Visibility level for this tool. Default: Direct (always visible).
Sourcefn should_activate(&self, _ctx: &ActivationContext) -> bool
fn should_activate(&self, _ctx: &ActivationContext) -> bool
Activation condition for Deferred tools. Ignored for Direct/Hidden.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".