Skip to main content

RunConfig

Struct RunConfig 

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

Thread (session) id. Stable across interrupt/resume; namespaces all checkpoints for this run. Required for persistence and resume.

§max_steps: usize

Maximum 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

Source

pub fn new(thread_id: impl Into<String>) -> Self

A config for thread_id with the default step limit.

Source

pub fn with_max_steps(self, max_steps: usize) -> Self

Builder-style: override the step limit.

Source

pub fn with_resume(self, value: Value) -> Self

Builder-style: set the resume value.

Source

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.

Source

pub fn with_event_tx(self, tx: Sender<GraphEvent>) -> Self

Builder-style: attach a streaming event sink.

Source

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).

Source

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).

Source

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.

Source

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).

Source

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).

Source

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.

Source

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).

Source

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).

Source

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.

Source

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 Clone for RunConfig

Source§

fn clone(&self) -> Self

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 RunConfig

Source§

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

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

impl Default for RunConfig

Source§

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.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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: Sized + 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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