pub struct ToolContext {
pub cwd: PathBuf,
pub cancel: CancellationToken,
pub permission_checker: Arc<PermissionChecker>,
pub verbose: bool,
pub plan_mode: bool,
pub file_cache: Option<Arc<Mutex<FileCache>>>,
pub denial_tracker: Option<Arc<Mutex<DenialTracker>>>,
pub task_manager: Option<Arc<TaskManager>>,
pub session_allows: Option<Arc<Mutex<HashSet<String>>>>,
pub permission_prompter: Option<Arc<dyn PermissionPrompter>>,
pub sandbox: Option<Arc<SandboxExecutor>>,
}Expand description
Context passed to every tool during execution.
Provides the working directory, cancellation token, permission checker, file cache, and other shared state. Created by the executor before each tool call.
Fields§
§cwd: PathBufCurrent working directory.
cancel: CancellationTokenCancellation token for cooperative cancellation.
permission_checker: Arc<PermissionChecker>Permission checker instance.
verbose: boolWhether to produce verbose output.
plan_mode: boolPlan mode: only read-only tools allowed.
file_cache: Option<Arc<Mutex<FileCache>>>File content cache for avoiding redundant reads.
denial_tracker: Option<Arc<Mutex<DenialTracker>>>Permission denial tracker for reporting.
task_manager: Option<Arc<TaskManager>>Shared background task manager.
session_allows: Option<Arc<Mutex<HashSet<String>>>>Tools allowed for the rest of the session (via “Allow for session” prompt).
permission_prompter: Option<Arc<dyn PermissionPrompter>>Permission prompter for interactive approval.
sandbox: Option<Arc<SandboxExecutor>>Process-level sandbox executor.
None means sandboxing is unavailable for this context
(e.g. parallel read-only retry paths); subprocess-spawning tools
should treat None as “pass through unchanged”. The main query
loop populates this from crate::config::SandboxConfig.