pub trait Tool: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn description(&self) -> &str;
fn parameters(&self) -> Value;
fn execute<'life0, 'async_trait>(
&'life0 self,
params: Value,
ctx: ToolContext,
) -> Pin<Box<dyn Future<Output = Result<String>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
// Provided methods
fn extension_id(&self) -> Option<&str> { ... }
fn origin(&self) -> ToolOrigin { ... }
fn effect(&self) -> ToolEffect { ... }
fn concurrency_key(
&self,
_validated_input: &Value,
) -> Option<ConcurrencyKey> { ... }
}Expand description
The core trait for all tools. Implement this to add a new tool.
Required Methods§
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Human-readable description sent to the model.
Sourcefn parameters(&self) -> Value
fn parameters(&self) -> Value
JSON Schema for the tool’s parameters.
Provided Methods§
Sourcefn extension_id(&self) -> Option<&str>
fn extension_id(&self) -> Option<&str>
Owning extension id for tools registered by an extension. Built-in tools return None.
Sourcefn origin(&self) -> ToolOrigin
fn origin(&self) -> ToolOrigin
Runtime-origin identity used for catalog provenance. Conservative by
default: tools that declare nothing are Unknown (fail-closed source
trust), and tools that declare an owning extension classify as
extension-provided. Built-in implementations override this explicitly.
Sourcefn effect(&self) -> ToolEffect
fn effect(&self) -> ToolEffect
Conservative effect class (Task 24, spec §8.2). The default keeps
unknown/dynamic tools NonIdempotent — serialized execution;
implementations opt IN to weaker classes explicitly.
Sourcefn concurrency_key(&self, _validated_input: &Value) -> Option<ConcurrencyKey>
fn concurrency_key(&self, _validated_input: &Value) -> Option<ConcurrencyKey>
Key resolution derived from validated input. Serialize explicitly
fails closed into the global mutation lane; None is the conservative
default for tools with no key support.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".