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 agentic_search_config: Option<AgenticSearchConfig>,
pub agentic_parse_config: Option<AgenticParseConfig>,
pub document_parser_config: Option<DocumentParserConfig>,
pub sandbox: Option<Arc<dyn BashSandbox>>,
pub command_env: Option<Arc<HashMap<String, String>>>,
pub document_parsers: Option<Arc<DocumentParserRegistry>>,
/* private fields */
}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
agentic_search_config: Option<AgenticSearchConfig>Optional built-in configuration for agentic_search.
agentic_parse_config: Option<AgenticParseConfig>Optional built-in configuration for agentic_parse.
document_parser_config: Option<DocumentParserConfig>Optional built-in configuration for document context extraction.
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.
document_parsers: Option<Arc<DocumentParserRegistry>>Optional document parser registry for tools that need richer extraction from non-plaintext files before handing context to the model.
Built-in tools such as agentic_search and agentic_parse use this
registry to support PDF, Excel, Word, and other binary formats. When
None, callers may still supply a default registry at a higher layer.
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_agentic_search_config(self, config: AgenticSearchConfig) -> Self
pub fn with_agentic_search_config(self, config: AgenticSearchConfig) -> Self
Set the built-in agentic_search configuration.
Sourcepub fn with_agentic_parse_config(self, config: AgenticParseConfig) -> Self
pub fn with_agentic_parse_config(self, config: AgenticParseConfig) -> Self
Set the built-in agentic_parse configuration.
Sourcepub fn with_document_parser_config(self, config: DocumentParserConfig) -> Self
pub fn with_document_parser_config(self, config: DocumentParserConfig) -> Self
Set the built-in document context extraction 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_document_parsers(
self,
registry: Arc<DocumentParserRegistry>,
) -> Self
pub fn with_document_parsers( self, registry: Arc<DocumentParserRegistry>, ) -> Self
Set the document parser registry used by document context tools.
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 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