LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
  • Stream
LangGraph SDK
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Server
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
LangGraph Checkpoint Redis
  • Shallow
  • Store
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
  • Cli
LangGraph API
LangGraph CLI
LangGraph CUA
  • Utils
LangGraph Supervisor
LangGraph Swarm
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangGraph
WebChannelsPregelPrebuiltRemoteStream
LangGraph SDK
ClientAuthReactLoggingReact UiServer
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
LangGraph Checkpoint Redis
ShallowStore
LangGraph Checkpoint SQLite
LangGraph Checkpoint Validation
Cli
LangGraph API
LangGraph CLI
LangGraph CUA
Utils
LangGraph Supervisor
LangGraph Swarm
Language
Theme
JavaScript@langchain/langgraphchannels
Module●Since v1.0

channels

Copy
import { ... } from "@langchain/langgraph/channels";

Functions

function
channelsFromCheckpoint→ Promise<Cc>

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.

function
createCheckpoint→ Checkpoint
function
deltaChannelsToSnapshot→ Set<string>

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. Pure predicate — no mutation.

function
empty→ Cc
function
exitDeltaTaskId→ string

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

function
isDeltaChannel→ boolean

Structural check for a DeltaChannel without importing it (avoids an import cycle: delta.ts imports base.ts).

Classes

class
LastValueAfterFinish

Stores the last value received, but only made available after finish(). Once made available, clears the value.

class
BinaryOperatorAggregate

Stores the result of applying a binary operator to the current value and each new value.

class
DeltaChannel

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.

Interfaces

interface
AnyValue

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.

interface
DynamicBarrierValue

A channel that switches between two states

  • in the "priming" state it can't be read from.
    • if it receives a WaitForNames update, it switches to the "waiting" state.
  • in the "waiting" state it collects named values until all are received.
    • once all named values are received, it can be read once, and it switches back to the "priming" state.
interface
EphemeralValue

Stores the value received in the step immediately preceding, clears after.

interface
NamedBarrierValue

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.

interface
Topic

A configurable PubSub Topic.

interface
WaitForNames

Type Aliases

typeAlias
BinaryOperator: (a: ValueType, b: UpdateType)
typeAlias
DeltaReducer: (state: ValueType, writes: UpdateType[])

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.

View source on GitHub