Skip to main content

ExecutionContext

Struct ExecutionContext 

Source
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:

SourceCWD priorityEnv priority
ToolCall.context.cwd / env_overrides1 (highest)1 (highest)
Named registry entry (looked up by name)22
Skill env (set_skill_env)3
default_env registry entry (when set)34
Process CWD4
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

Source

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.

Source

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.

Source

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.

Source

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

pub fn with_envs<K, V, I>(self, iter: I) -> Self
where K: Into<String>, V: Into<String>, I: IntoIterator<Item = (K, V)>,

Add multiple environment variable overrides from an iterator.

Equivalent to calling with_env for each pair.

Source§

impl ExecutionContext

Source

pub fn name(&self) -> Option<&str>

The logical environment name, if set.

Source

pub fn cwd(&self) -> Option<&Path>

The working directory override, if set.

Source

pub fn env_overrides(&self) -> &BTreeMap<String, String>

The environment variable overrides.

Source

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

Source§

fn clone(&self) -> ExecutionContext

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ExecutionContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ExecutionContext

Source§

fn default() -> ExecutionContext

Returns the “default value” for a type. Read more
Source§

impl PartialEq for ExecutionContext

Source§

fn eq(&self, other: &ExecutionContext) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for ExecutionContext

Source§

impl StructuralPartialEq for ExecutionContext

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more