Skip to main content

Tool

Trait Tool 

Source
pub trait Tool: Send + Sync {
Show 13 methods // Required methods fn name(&self) -> &str; fn description(&self) -> &str; fn parameters_schema(&self) -> Value; fn execute<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 dyn ToolContext, args: Value, ) -> Pin<Box<dyn Future<Output = ToolResult<ToolOutput>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; // Provided methods fn response_schema(&self) -> Option<Value> { ... } fn is_read_only(&self) -> bool { ... } fn is_concurrency_safe(&self) -> bool { ... } fn is_long_running(&self) -> bool { ... } fn side_effects(&self) -> SideEffects { ... } fn requires_approval(&self) -> bool { ... } fn approval_reason(&self) -> Option<String> { ... } fn required_scopes(&self) -> &[&str] { ... } fn to_spec(&self) -> ToolSpec { ... }
}
Expand description

An executable tool that can be called by an LLM.

Required Methods§

Source

fn name(&self) -> &str

Returns the tool’s name (visible to the model).

Source

fn description(&self) -> &str

Returns a human-readable description of the tool.

Source

fn parameters_schema(&self) -> Value

Returns the JSON Schema for the tool’s parameters.

Source

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, ctx: &'life1 dyn ToolContext, args: Value, ) -> Pin<Box<dyn Future<Output = ToolResult<ToolOutput>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Executes the tool with the given context and arguments.

Provided Methods§

Source

fn response_schema(&self) -> Option<Value>

Returns the JSON Schema for the tool’s response (if any).

Source

fn is_read_only(&self) -> bool

Returns true if the tool is read-only (no side effects).

Source

fn is_concurrency_safe(&self) -> bool

Returns true if the tool is safe to run concurrently.

Source

fn is_long_running(&self) -> bool

Returns true if the tool is expected to run for a long time.

Source

fn side_effects(&self) -> SideEffects

Returns the side effects the tool may produce.

Source

fn requires_approval(&self) -> bool

Returns true if the tool requires human approval before execution.

Source

fn approval_reason(&self) -> Option<String>

Returns the reason approval is needed, if applicable.

Source

fn required_scopes(&self) -> &[&str]

Returns the scopes required to use this tool.

Source

fn to_spec(&self) -> ToolSpec

Produces a ToolSpec for this tool.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§