pub struct ToolDefinition {
pub name: String,
pub description: String,
pub input_schema: ToolInputSchema,
pub annotations: Option<ToolAnnotations>,
pub should_defer: Option<bool>,
pub always_load: Option<bool>,
pub is_mcp: Option<bool>,
pub search_hint: Option<String>,
pub aliases: Option<Vec<String>>,
pub user_facing_name: Option<String>,
pub interrupt_behavior: Option<String>,
}Fields§
§name: String§description: String§input_schema: ToolInputSchema§annotations: Option<ToolAnnotations>Optional annotations for tool classification
should_defer: Option<bool>When true, this tool is deferred (requires ToolSearch to load)
always_load: Option<bool>When true, this tool is never deferred (full schema always sent)
is_mcp: Option<bool>When true, this is an MCP tool
search_hint: Option<String>Short capability phrase for keyword search (3-10 words)
aliases: Option<Vec<String>>Optional aliases for backwards compatibility when a tool is renamed
user_facing_name: Option<String>Human-readable name for display in the UI (e.g., “Update” vs “Edit”)
interrupt_behavior: Option<String>Interrupt behavior: ‘cancel’ (stop on user interrupt) or ‘block’ (wait for completion)
Implementations§
Source§impl ToolDefinition
impl ToolDefinition
Sourcepub fn new(name: &str, description: &str, input_schema: ToolInputSchema) -> Self
pub fn new(name: &str, description: &str, input_schema: ToolInputSchema) -> Self
Create a new tool definition (annotations defaults to None)
Sourcepub fn with_deferred(self, should_defer: bool) -> Self
pub fn with_deferred(self, should_defer: bool) -> Self
Build with deferred loading support
Sourcepub fn with_always_load(self) -> Self
pub fn with_always_load(self) -> Self
Mark as always loaded (never deferred)
Sourcepub fn with_search_hint(self, hint: &str) -> Self
pub fn with_search_hint(self, hint: &str) -> Self
Set search hint for keyword search
Sourcepub fn interrupt_behavior(&self) -> InterruptBehavior
pub fn interrupt_behavior(&self) -> InterruptBehavior
Get interrupt behavior: ‘cancel’ (stop on user interrupt) or ‘block’ (wait for completion) Default: ‘block’
Sourcepub fn backfill_observable_input(&self, _input: &mut Value)
pub fn backfill_observable_input(&self, _input: &mut Value)
Backfill observable input before observers see it (hooks, events, transcript).
Mutates in place to add legacy/derived fields. Must be idempotent.
Default: no-op. Override via with_interrupt_behavior for tools that need it.
Sourcepub fn is_concurrency_safe(&self, _input: &Value) -> bool
pub fn is_concurrency_safe(&self, _input: &Value) -> bool
Check if tool can run concurrently (default: false)
Sourcepub fn is_read_only(&self, _input: &Value) -> bool
pub fn is_read_only(&self, _input: &Value) -> bool
Check if tool only reads data (default: false)
Sourcepub fn is_destructive(&self, input: &Value) -> bool
pub fn is_destructive(&self, input: &Value) -> bool
Check if tool performs destructive operations (default: false)
Sourcepub fn is_idempotent(&self) -> bool
pub fn is_idempotent(&self) -> bool
Check if tool is idempotent (can be run multiple times safely)
Sourcepub fn get_use_summary(&self, input: &Value) -> String
pub fn get_use_summary(&self, input: &Value) -> String
Get tool use summary for compact views
Trait Implementations§
Source§impl Clone for ToolDefinition
impl Clone for ToolDefinition
Source§fn clone(&self) -> ToolDefinition
fn clone(&self) -> ToolDefinition
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more