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<Arc<SearchConfig>>,
pub sandbox: Option<Arc<dyn BashSandbox>>,
pub command_env: Option<Arc<HashMap<String, String>>>,
pub workspace_services: Arc<WorkspaceServices>,
}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<Arc<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.
workspace_services: Arc<WorkspaceServices>Host-provided workspace capabilities used by built-in 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 with_workspace_services(self, services: Arc<WorkspaceServices>) -> Self
pub fn with_workspace_services(self, services: Arc<WorkspaceServices>) -> Self
Set host-provided workspace capabilities for built-in tools.
Sourcepub fn resolve_workspace_path(&self, path: &str) -> Result<WorkspacePath>
pub fn resolve_workspace_path(&self, path: &str) -> Result<WorkspacePath>
Normalize a user-supplied path through the configured workspace backend.
Sourcepub fn resolve_path(&self, path: &str) -> Result<PathBuf>
👎Deprecated: Use resolve_workspace_path() and route I/O through workspace_services.fs() for non-local backends
pub fn resolve_path(&self, path: &str) -> Result<PathBuf>
Use resolve_workspace_path() and route I/O through workspace_services.fs() for non-local backends
Resolve path relative to workspace, ensuring it stays within sandbox.
Deprecated: returns a host-filesystem PathBuf that is meaningless for
virtual / DFS / browser workspace backends. New code should call
Self::resolve_workspace_path and route I/O through
workspace_services.fs() instead.
Sourcepub fn resolve_path_for_write(&self, path: &str) -> Result<PathBuf>
👎Deprecated: Use resolve_workspace_path() and route I/O through workspace_services.fs() for non-local backends
pub fn resolve_path_for_write(&self, path: &str) -> Result<PathBuf>
Use resolve_workspace_path() and route I/O through workspace_services.fs() for non-local backends
Resolve path for writing (allows non-existent files).
Deprecated: see Self::resolve_path.
Trait Implementations§
Source§impl Clone for ToolContext
impl Clone for ToolContext
Source§fn clone(&self) -> ToolContext
fn clone(&self) -> ToolContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more