pub struct RunConfig {Show 14 fields
pub thread_id: String,
pub max_steps: usize,
pub resume: Option<Value>,
pub checkpoint_id: Option<String>,
pub event_tx: Option<Sender<GraphEvent>>,
pub clock: Option<Clock>,
pub rng: Option<RngSource>,
pub journal: Option<Journal>,
pub policy_version: Option<PolicyVersion>,
pub graph_version: Option<String>,
pub cancellation: Option<CancellationToken>,
pub manifest: Option<RunManifest>,
pub effect_approvals: Vec<ApprovalToken>,
pub effect_admission: Option<EffectAdmissionContext>,
}Expand description
Per-run configuration (the LangGraph RunnableConfig analog).
Fields§
§thread_id: StringThread (session) id. Stable across interrupt/resume; namespaces all checkpoints for this run. Required for persistence and resume.
max_steps: usizeMaximum number of super-steps before the run aborts with
crate::error::RustyError::Graph (the LangGraph
recursion_limit / GraphRecursionError guard). Default: 1000.
resume: Option<Value>Resume value for continuing an interrupted run. When set, the
executor restores the latest checkpoint for thread_id and
re-executes the checkpointed next-node set with
crate::node::NodeContext::resume_value returning this value.
The value is broadcast: every node scheduled in the first
super-step after the resume observes it, not only the node that
originally interrupted (a suspension checkpoint re-schedules the
whole active set — see ExecutionOutcome::Interrupted). Nodes that
should react only when they themselves were resumed must key off
their own state, not the presence of a resume value.
checkpoint_id: Option<String>Replay/time-travel handle: the id of a specific checkpoint of
thread_id to resume from. When set, the executor loads that
checkpoint (not the latest) and continues the run from its state and
next-node set. Requires a checkpointer on the executor.
Combines with resume: checkpoint_id selects where the run
restarts, resume (when also set) is delivered as the resume value to
the first super-step, exactly as in interrupt/resume.
Safe pattern: replaying on the same thread appends new history on
top of the old timeline, so prefer forking first —
crate::checkpoint::Checkpointer::fork_thread the thread into a new
thread id, then run the fork with checkpoint_id set. Direct replay
on the original thread is supported for cases where appended history
is acceptable.
event_tx: Option<Sender<GraphEvent>>Optional event sink for streaming: the executor emits GraphEvents
as the run progresses (node start/end, state updates, checkpoints,
super-step boundaries). Consumers implement LangGraph’s stream modes
(values / updates / tasks / …) as filters over this stream.
clock: Option<Clock>Flight Recorder determinism seam (R0.5): the run’s time source. Every
executor timestamp — event recorded_at, node latencies, checkpoint
created_at — is read through it. None (the default) is the system
wall clock, byte-identical to pre-R0.5 behavior. Attach
Clock::Logical to make a recorded run re-drivable.
rng: Option<RngSource>Flight Recorder determinism seam (R0.5): the run’s randomness source.
Checkpoint ids (and the run id, when the executor creates the
journal) are minted through it. None (the default) is OS entropy,
byte-identical to pre-R0.5 behavior; RngSource::Seeded makes the
id stream reproducible.
journal: Option<Journal>Flight Recorder (R0.5): attach a pre-built journal for this run. Node
closures capture a clone of the same Journal to record their own
model/tool/remote/WASM calls into the run’s evidence (the journal
stamps sequence numbers and timestamps itself). When None, the
executor creates a fresh journal per run; either way the run’s
journal is retrievable afterwards via Executor::journal.
policy_version: Option<PolicyVersion>Flight Recorder (R0.5): the executor policy active for this run,
stamped into every checkpoint header. None records the static
default (PolicyVersion::STATIC_V0) — except on resume (R0.8 wave
4), where the run inherits the version its checkpoint header pins so
an in-flight run is immune to mid-run promotions. An explicit pin
always wins over inheritance.
graph_version: Option<String>Flight Recorder (R0.5): the application’s own graph version string,
stamped into every checkpoint header next to the topology hash.
None records "unversioned". Bump it when node bodies change in
ways the topology hash cannot see.
cancellation: Option<CancellationToken>Cooperative cancellation (R0.6 wave 2c, drain). When set, the
executor checks the token at every super-step boundary and, once
it is cancelled, stops the run before starting the next super-step,
returning RustyError::Cancelled.
The boundary is the only cancellation point, deliberately: a super-step is transactional (its nodes run off an immutable snapshot and its writes merge atomically), and its boundary checkpoint is already persisted by the time the token is observed — so a cancelled run resumes from exactly where it stopped, with no torn step and no lost writes. Cancellation granularity is therefore one super-step; work inside the in-flight step runs to its barrier. This is the hook graceful shutdown uses: a draining server cancels the token and every in-flight run parks itself at a resumable checkpoint instead of being torn down mid-step.
manifest: Option<RunManifest>Effect kernel v2 (R0.7): the versioned run manifest — prompts, tool
schemas, model and parameters, memory schema, capsule versions the run
pins. Stamped into every checkpoint header so a resumed run keeps
executing against its pinned versions (see
crate::record::RunManifest for the upgrade-safety contract).
None (the default) pins nothing and leaves checkpoint bytes
byte-identical to R0.5/R0.6.
effect_approvals: Vec<ApprovalToken>Effect kernel v2 (R0.7): the approval tokens this run carries for its
irreversible effects (see crate::effects::ApprovalToken). The
executor consults them when Executor::with_effect_admission has
enabled the guarded tool path. Empty by default; an irreversible call
dispatched through that path then fails admission before its body
runs.
effect_admission: Option<EffectAdmissionContext>Shadow runs (R0.12 wave 4): an explicit admission context for this
run, overriding the one the executor would otherwise build from
Executor::with_effect_admission. A shadow deployment builds a
context whose boundary refuses every effect above read-only and serves
refused calls from the recorded world (see
crate::effects::EffectAdmissionContext::shadow); injecting it here
is what makes the run execute against that boundary instead of the
production one. None (the default) is byte-identical to prior
behavior.
Implementations§
Source§impl RunConfig
impl RunConfig
Sourcepub fn new(thread_id: impl Into<String>) -> Self
pub fn new(thread_id: impl Into<String>) -> Self
A config for thread_id with the default step limit.
Sourcepub fn with_max_steps(self, max_steps: usize) -> Self
pub fn with_max_steps(self, max_steps: usize) -> Self
Builder-style: override the step limit.
Sourcepub fn with_resume(self, value: Value) -> Self
pub fn with_resume(self, value: Value) -> Self
Builder-style: set the resume value.
Sourcepub fn with_checkpoint_id(self, checkpoint_id: impl Into<String>) -> Self
pub fn with_checkpoint_id(self, checkpoint_id: impl Into<String>) -> Self
Builder-style: replay from a specific checkpoint of thread_id
(time travel). See the RunConfig::checkpoint_id field docs for
semantics and the fork-first safe pattern.
Sourcepub fn with_event_tx(self, tx: Sender<GraphEvent>) -> Self
pub fn with_event_tx(self, tx: Sender<GraphEvent>) -> Self
Builder-style: attach a streaming event sink.
Sourcepub fn with_clock(self, clock: Clock) -> Self
pub fn with_clock(self, clock: Clock) -> Self
Builder-style: source the run’s time from clock (Flight Recorder
determinism seam; see the RunConfig::clock field docs).
Sourcepub fn with_rng(self, rng: RngSource) -> Self
pub fn with_rng(self, rng: RngSource) -> Self
Builder-style: source the run’s randomness from rng (Flight
Recorder determinism seam; see the RunConfig::rng field docs).
Sourcepub fn with_journal(self, journal: Journal) -> Self
pub fn with_journal(self, journal: Journal) -> Self
Builder-style: record the run into journal (Flight Recorder; see
the RunConfig::journal field docs). When the config carries no
explicit RunConfig::clock, the executor also reads time from the
attached journal’s clock, keeping one time source per run.
Sourcepub fn with_policy_version(self, version: PolicyVersion) -> Self
pub fn with_policy_version(self, version: PolicyVersion) -> Self
Builder-style: stamp the active executor policy version into every
checkpoint header (see the RunConfig::policy_version field docs).
Sourcepub fn with_graph_version(self, version: impl Into<String>) -> Self
pub fn with_graph_version(self, version: impl Into<String>) -> Self
Builder-style: stamp the application’s graph version into every
checkpoint header (see the RunConfig::graph_version field docs).
Sourcepub fn with_cancellation(self, token: CancellationToken) -> Self
pub fn with_cancellation(self, token: CancellationToken) -> Self
Builder-style: make the run cooperatively cancellable (see the
RunConfig::cancellation field docs). The token is observed only at
super-step boundaries: cancelling it stops the run after the
in-flight step’s barrier and boundary checkpoint, so the run is left
resumable from exactly that checkpoint with RustyError::Cancelled.
Sourcepub fn with_manifest(self, manifest: RunManifest) -> Self
pub fn with_manifest(self, manifest: RunManifest) -> Self
Builder-style: pin the run’s versioned manifest into every checkpoint
header (see the RunConfig::manifest field docs).
Sourcepub fn with_effect_approvals(
self,
approvals: impl IntoIterator<Item = ApprovalToken>,
) -> Self
pub fn with_effect_approvals( self, approvals: impl IntoIterator<Item = ApprovalToken>, ) -> Self
Builder-style: carry approval tokens for the run’s irreversible
effects (see the RunConfig::effect_approvals field docs).
Sourcepub fn with_effect_admission_context(
self,
context: EffectAdmissionContext,
) -> Self
pub fn with_effect_admission_context( self, context: EffectAdmissionContext, ) -> Self
Builder-style: inject an explicit admission context for this run (see
the RunConfig::effect_admission field docs). Shadow deployments
use it to run the graph against the shadow boundary instead of the
production one.
Sourcepub fn token_tx(&self) -> Option<Sender<GraphEvent>>
pub fn token_tx(&self) -> Option<Sender<GraphEvent>>
A clone of the event sink sender, for wiring into nodes that stream
GraphEvent::Token deltas (LangGraph’s messages stream mode).
Typical flow: create the channel, call config.token_tx() to obtain
the clone a node closure captures, then hand config to
Executor::run. None when no sink is attached. See the
crate::llm::ChatModel rustdoc for the full pattern.
Trait Implementations§
Source§impl Default for RunConfig
impl Default for RunConfig
Source§fn default() -> Self
fn default() -> Self
A config with an empty thread_id and the default step limit —
identical to RunConfig::new(""). Derived Default would zero
max_steps, so any default()-built run would instantly trip the
step guard; keep this impl in sync with RunConfig::new.