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 default_parser_config: Option<DefaultParserConfig>,
pub sandbox: Option<Arc<dyn BashSandbox>>,
pub command_env: Option<Arc<HashMap<String, String>>>,
pub document_parsers: Option<Arc<DocumentParserRegistry>>,
}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.
default_parser_config: Option<DefaultParserConfig>Optional built-in configuration for DefaultParser.
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 plugins that need to read non-plaintext files.
Plugins 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_default_parser_config(self, config: DefaultParserConfig) -> Self
pub fn with_default_parser_config(self, config: DefaultParserConfig) -> Self
Set the built-in DefaultParser 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.
Plugins such as agentic-search and agentic-parse use this to support
non-plaintext formats (PDF, Excel, etc.).
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