pub trait Tool: Send + Sync {
// Required methods
fn definition(&self) -> ToolDefinition;
fn execute<'life0, 'async_trait>(
&'life0 self,
params: Value,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn definition_with_context(&self, _ctx: &ToolContext) -> ToolDefinition { ... }
fn risk_level(&self) -> RiskLevel { ... }
}Required Methods§
Sourcefn definition(&self) -> ToolDefinition
fn definition(&self) -> ToolDefinition
Get tool definition (must implement)
fn execute<'life0, 'async_trait>(
&'life0 self,
params: Value,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Provided Methods§
Sourcefn definition_with_context(&self, _ctx: &ToolContext) -> ToolDefinition
fn definition_with_context(&self, _ctx: &ToolContext) -> ToolDefinition
Get tool definition with context (for dynamic descriptions)
Default implementation calls definition(). Override this method if you need context-aware descriptions (e.g., different text when CodeGraph is available).
Sourcefn risk_level(&self) -> RiskLevel
fn risk_level(&self) -> RiskLevel
Risk level of this tool. Defaults to Safe (read-only). Override in tools that modify state.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".