pub struct ToolContext {
pub workspace: PathBuf,
pub session_id: Option<String>,
pub event_tx: Option<ToolEventSender>,
pub search_config: Option<SearchConfig>,
pub sandbox: Option<Arc<dyn BashSandbox>>,
}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
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.
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_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.
When set, bash commands are routed through the sandbox instead of
std::process::Command.
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
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ToolContext
impl !RefUnwindSafe for ToolContext
impl Send for ToolContext
impl Sync for ToolContext
impl Unpin for ToolContext
impl UnsafeUnpin for ToolContext
impl !UnwindSafe for ToolContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more