pub trait ToolContext: RunContext {
// Required method
fn tool_call(&self) -> &ToolCall;
// Provided methods
fn emit_progress(&self, status: &str, data: Value) { ... }
fn search_memory(&self, _query: &str, _limit: usize) -> Vec<MemoryEntry> { ... }
}Expand description
Context for tool execution.
Extends RunContext with tool-specific capabilities:
- Access to the current tool call
- Streaming progress output
- Memory search (for tools that need context from long-term memory)
Required Methods§
Provided Methods§
Sourcefn emit_progress(&self, status: &str, data: Value)
fn emit_progress(&self, status: &str, data: Value)
Emits a progress update for the current tool execution.
Progress events are streamed to consumers so they can observe long-running tool operations in real time.
Sourcefn search_memory(&self, _query: &str, _limit: usize) -> Vec<MemoryEntry>
fn search_memory(&self, _query: &str, _limit: usize) -> Vec<MemoryEntry>
Searches long-term memory for context relevant to the current tool call.
The default implementation returns an empty result. Implementations with access to an embedding store should override this.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".