import { ... } from "@langchain/langgraph/channels";Hydrate channels from a checkpoint, reconstructing any DeltaChannel
whose value is absent from channel_values by replaying ancestor writes.
For most channels (and for delta channels with a DeltaSnapshot or a
migrated plain value in channel_values), emptyChannels is
sufficient and no saver access is required. When a delta channel is absent
from channel_values, an ancestor walk via saver.getDeltaChannelHistory
finds the nearest seed and accumulates the writes between it and the
target. All delta channels needing replay are batched into a single saver
call. Pass deltaWritesVersioned for a checkpoint whose metadata carries
DELTA_WRITES_VERSIONED, so delta channels without a version are
left empty instead of walked.
Return the set of DeltaChannel names that should snapshot now.
A channel snapshots when EITHER its accumulated update count reaches
snapshotFrequency OR the total supersteps since its last snapshot reaches
DELTA_MAX_SUPERSTEPS_SINCE_SNAPSHOT. Given channelVersions, a channel
without a version is skipped: it was never written on this branch, so it
has nothing to snapshot. Pass undefined on a branch without
DELTA_WRITES_VERSIONED, where such a channel can still hold writes
and this snapshot is what bounds its walk. Pure predicate, no mutation.
DeltaChannels a branch starting from this checkpoint must snapshot.
A checkpoint's pending writes belong to the child that consumed them, and
nothing records which child that was. A new branch snapshots every delta
channel they touch, so its ancestor walk never replays them (port of
Python #8548's delta_channels_with_pending_writes).
Synthetic task id for exit-mode writes of a superstep after the anchor's own.
Sorts after every real task id, in step order, so replay keeps them after
the anchor's own superstep whether a saver orders writes by task path
(writesSortKey) or by task id. Mirrors Python's
exit_delta_late_task_id exactly, including the two hexadecimal step
groups (step is split across them).
Synthetic task id for exit-mode DeltaChannel writes.
Embeds the superstep in the first UUID group so ORDER BY task_id, idx
preserves chronological order while remaining a valid RFC UUID (required by
Postgres checkpoint_writes.task_id uuid columns). Never NULL_TASK_ID:
readers apply writes under it as the anchor checkpoint's own pending writes.
Structural check for a DeltaChannel without importing it (avoids an
import cycle: delta.ts imports base.ts).
Stores the last value received, but only made available after finish(). Once made available, clears the value.
Stores the result of applying a binary operator to the current value and each new value.
Reducer channel that stores only a sentinel in checkpoint blobs and reconstructs state by replaying ancestor writes through the reducer.
DeltaChannel avoids re-serializing the full accumulated value at every
step. Instead of writing the value into channel_values, the channel is
omitted entirely and its state is reconstructed on read by walking the
ancestor chain and replaying the per-step writes through the reducer (see
BaseCheckpointSaver.getDeltaChannelHistory).
Snapshot cadence is driven by two counters: a per-channel update count and
the total supersteps since the last snapshot. A full DeltaSnapshot
blob is written when EITHER the update count reaches snapshotFrequency OR
the supersteps count reaches the system-wide
DELTA_MAX_SUPERSTEPS_SINCE_SNAPSHOT bound (default 5000), bounding replay
depth even for channels that stop receiving writes.
Stores the last value received, assumes that if multiple values are received, they are all equal.
Note: Unlike 'LastValue' if multiple nodes write to this channel in a single step, the values will be continuously overwritten.
A channel that switches between two states
Stores the value received in the step immediately preceding, clears after.
A channel that waits until all named values are received before making the value available.
This ensures that if node N and node M both write to channel C, the value of C will not be updated until N and M have completed updating.
A configurable PubSub Topic.
A batch reducer for use with DeltaChannel.
Receives the current accumulated value and a batch of writes in one call,
returning the new accumulated value:
reducer(state, [write1, write2, ...]) -> newState.
Reducers must be deterministic and batching-invariant (associative across folds): applying two consecutive write batches separately must produce the same state as applying their concatenation once:
reducer(reducer(state, xs), ys) === reducer(state, xs.concat(ys))
This lets LangGraph replay checkpointed writes in larger batches than they
were originally produced without changing reconstructed state. If your
reducer is not associative, use BinaryOperatorAggregate instead —
DeltaChannel is not a drop-in replacement for every reducer.