pub struct RunContext {
pub assigned_file: Option<PathBuf>,
pub max_turns_override: Option<u32>,
pub working_dir: Option<PathBuf>,
pub model: Option<String>,
}Expand description
Per-invocation context threaded from orchestrator to agent runner.
Why: Previously, orchestrators (the wave loop in particular) passed
per-call directives like the assigned file path and a tightened turn
budget via process-global env vars (std::env::set_var). That is
unsound in Rust 2024 because env mutation is not thread-safe under
multi-threaded tokio runtimes. Threading a RunContext through the
AgentRunner trait replaces the shared mutation with a per-call value
that runners can apply to the child process (via Command::env / current_dir)
without touching the parent’s environment.
What: Carries optional overrides — the assigned file for single-file
wave-loop invocations, a per-call max-turns cap, and a working directory
that the runner should use as the subprocess CWD.
Test: Exercised indirectly through the wave-loop and runner dispatch
tests (wave_loop_runs_one_agent_per_file, runner unit tests).
Fields§
§assigned_file: Option<PathBuf>When Some(path), the runner should scope any file-writing tool to
exactly this relative path. The wave loop sets this so each per-file
agent can only emit its assigned file.
max_turns_override: Option<u32>When Some(n), the runner should enforce a max-turns cap of n for
this single invocation, overriding whatever the agent’s TOML sets.
working_dir: Option<PathBuf>When Some(dir), the runner should use dir as the subprocess’s
current working directory. Needed for the claude-code runner so the
CLI’s file-writing tools resolve relative paths inside out_dir.
model: Option<String>When Some(model), the runner should use model as the LLM model for
this invocation, overriding the agent TOML’s [agent].model /
[llm].model_override. Sourced from the workflow phase’s
model field (#107, renamed from model_override in #359).
Why: Previously the workflow engine only logged phase.model
as “advisory” — it never reached the runner. For ClaudeCodeAgentRunner
this meant every phase used the plan-agent TOML’s model
(claude-sonnet-4-6) regardless of what config/workflows/*.json
specified. Threading the override through RunContext lets the runner
pass it as --model to the claude CLI (and via
TAGENT_MODEL_<AGENT> env for subprocess runners), preserving the
documented priority chain (env > phase override > agent TOML > default).
What: Optional string (e.g. "anthropic/claude-opus-4-6"). Runners that
don’t understand it are free to ignore it; the default
AgentRunner::run_with_context still falls back to run() for mock
test doubles.
Test: ClaudeCodeAgentRunner::run_with_config_ctx honors it; the
engine populates it from phase.model in both the non-wave
and wave-loop paths.
Trait Implementations§
Source§impl Clone for RunContext
impl Clone for RunContext
Source§fn clone(&self) -> RunContext
fn clone(&self) -> RunContext
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 RunContext
impl Debug for RunContext
Source§impl Default for RunContext
impl Default for RunContext
Source§fn default() -> RunContext
fn default() -> RunContext
Auto Trait Implementations§
impl Freeze for RunContext
impl RefUnwindSafe for RunContext
impl Send for RunContext
impl Sync for RunContext
impl Unpin for RunContext
impl UnsafeUnpin for RunContext
impl UnwindSafe for RunContext
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> 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