pub struct ToolContext {
pub workspace: PathBuf,
pub session_id: Option<String>,
pub event_tx: Option<ToolEventSender>,
pub agent_event_tx: Option<Sender<AgentEvent>>,
pub search_config: Option<SearchConfig>,
pub sandbox: Option<Arc<dyn BashSandbox>>,
pub command_env: Option<Arc<HashMap<String, String>>>,
}Expand description
Tool execution context
Provides tools with access to workspace and other runtime information.
Fields§
§workspace: PathBufWorkspace root directory (sandbox boundary)
session_id: Option<String>Optional session ID for session-aware tools
event_tx: Option<ToolEventSender>Optional sender for streaming tool output deltas during execution
agent_event_tx: Option<Sender<AgentEvent>>Optional agent event sender for tools that emit high-level agent events (e.g., SubagentStart)
search_config: Option<SearchConfig>Optional search configuration for web_search tool
sandbox: Option<Arc<dyn BashSandbox>>Optional sandbox for routing bash tool execution through A3S Box.
command_env: Option<Arc<HashMap<String, String>>>Optional command environment overrides for subprocess-based tools.
Implementations§
Source§impl ToolContext
impl ToolContext
pub fn new(workspace: PathBuf) -> Self
Sourcepub fn with_session_id(self, session_id: impl Into<String>) -> Self
pub fn with_session_id(self, session_id: impl Into<String>) -> Self
Set the session ID for this context
Sourcepub fn with_event_tx(self, tx: ToolEventSender) -> Self
pub fn with_event_tx(self, tx: ToolEventSender) -> Self
Set the event sender for streaming tool output
Sourcepub fn with_agent_event_tx(self, tx: Sender<AgentEvent>) -> Self
pub fn with_agent_event_tx(self, tx: Sender<AgentEvent>) -> Self
Set the agent event sender for high-level agent events (e.g., SubagentStart/End)
Sourcepub fn with_search_config(self, config: SearchConfig) -> Self
pub fn with_search_config(self, config: SearchConfig) -> Self
Set the search configuration
Sourcepub fn with_sandbox(self, sandbox: Arc<dyn BashSandbox>) -> Self
pub fn with_sandbox(self, sandbox: Arc<dyn BashSandbox>) -> Self
Set a sandbox executor for the bash tool.
Sourcepub fn with_command_env(self, env: Arc<HashMap<String, String>>) -> Self
pub fn with_command_env(self, env: Arc<HashMap<String, String>>) -> Self
Set environment overrides for subprocess-based tools such as bash.
Sourcepub fn resolve_path(&self, path: &str) -> Result<PathBuf>
pub fn resolve_path(&self, path: &str) -> Result<PathBuf>
Resolve path relative to workspace, ensuring it stays within sandbox
Sourcepub fn resolve_path_for_write(&self, path: &str) -> Result<PathBuf>
pub fn resolve_path_for_write(&self, path: &str) -> Result<PathBuf>
Resolve path for writing (allows non-existent files)
Trait Implementations§
Source§impl Clone for ToolContext
impl Clone for ToolContext
Source§fn clone(&self) -> ToolContext
fn clone(&self) -> ToolContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more