pub struct ExecutionContext { /* private fields */ }Expand description
Per-turn execution environment for a tool call.
When attached to a crate::ToolCall, executors that honour it (currently
crate::ShellExecutor) use these values instead of the process-level CWD and
skill env. None on ToolCall::context means “use the executor default” —
identical to today’s behaviour.
Cheaply clonable (single Arc) so the same context can be shared across
parallel tool calls in one DAG layer without copying the underlying data.
§Precedence
When the ShellExecutor resolves the effective (cwd, env) for a call, the
highest-priority source wins for each dimension:
| Source | CWD priority | Env priority |
|---|---|---|
ToolCall.context.cwd / env_overrides | 1 (highest) | 1 (highest) |
Named registry entry (looked up by name) | 2 | 2 |
Skill env (set_skill_env) | — | 3 |
default_env registry entry (when set) | 3 | 4 |
| Process CWD | 4 | — |
| Inherited process env (minus blocklist) | — | 5 (lowest) |
Attaching a context for telemetry tagging via env_overrides never silently
disables default_env — a more specific source simply overrides a less specific one.
Implementations§
Source§impl ExecutionContext
impl ExecutionContext
Sourcepub fn new() -> Self
pub fn new() -> Self
Construct an empty, untrusted context.
Env overrides supplied via with_env are subject to the
executor’s blocklist filter before reaching the subprocess.
Sourcepub fn with_name(self, name: impl Into<String>) -> Self
pub fn with_name(self, name: impl Into<String>) -> Self
Set the logical environment name.
The name is matched against [[execution.environments]] in the agent config.
An unknown name produces a crate::ToolError::Execution at dispatch time.
Sourcepub fn with_cwd(self, cwd: impl Into<PathBuf>) -> Self
pub fn with_cwd(self, cwd: impl Into<PathBuf>) -> Self
Set the working directory override.
Relative paths are joined with the process CWD inside resolve_context before
sandbox validation. Non-existent paths are a hard error — no fallback to the
process CWD.
Sourcepub fn with_env(self, key: impl Into<String>, value: impl Into<String>) -> Self
pub fn with_env(self, key: impl Into<String>, value: impl Into<String>) -> Self
Add a single environment variable override.
Overwrites any prior value for the same key. Untrusted contexts have the final
env re-filtered through the executor’s env_blocklist — blocklisted keys are
stripped regardless of their source.
Source§impl ExecutionContext
impl ExecutionContext
Sourcepub fn env_overrides(&self) -> &BTreeMap<String, String>
pub fn env_overrides(&self) -> &BTreeMap<String, String>
The environment variable overrides.
Sourcepub fn is_trusted(&self) -> bool
pub fn is_trusted(&self) -> bool
Whether this context was built via the trusted constructor.
Trusted contexts bypass the executor’s final env_blocklist pass.
Only contexts built from operator-authored TOML (via build_registry) are trusted.
§Trust downgrade
When a call-site context wraps a trusted registry entry by name (via
ExecutionContext::with_name) but the call-site context itself is untrusted,
resolve_context downgrades the effective trust flag to false. This prevents
LLM-authored wrappers from escalating privilege by naming a trusted registry entry.
Trait Implementations§
Source§impl Clone for ExecutionContext
impl Clone for ExecutionContext
Source§fn clone(&self) -> ExecutionContext
fn clone(&self) -> ExecutionContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ExecutionContext
impl Debug for ExecutionContext
Source§impl Default for ExecutionContext
impl Default for ExecutionContext
Source§fn default() -> ExecutionContext
fn default() -> ExecutionContext
Source§impl PartialEq for ExecutionContext
impl PartialEq for ExecutionContext
Source§fn eq(&self, other: &ExecutionContext) -> bool
fn eq(&self, other: &ExecutionContext) -> bool
self and other values to be equal, and is used by ==.impl Eq for ExecutionContext
impl StructuralPartialEq for ExecutionContext
Auto Trait Implementations§
impl Freeze for ExecutionContext
impl RefUnwindSafe for ExecutionContext
impl Send for ExecutionContext
impl Sync for ExecutionContext
impl Unpin for ExecutionContext
impl UnsafeUnpin for ExecutionContext
impl UnwindSafe for ExecutionContext
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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