LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangGraph
  • Web
  • Channels
  • Pregel
  • Prebuilt
  • Remote
  • Stream
LangGraph SDK
  • Ui
  • Client
  • Auth
  • React
  • Logging
  • React Ui
  • Utils
  • Server
  • Stream
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
  • Store
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
UiClientAuthReactLoggingReact UiUtilsServerStream
LangGraph Checkpoint
LangGraph Checkpoint MongoDB
LangGraph Checkpoint Postgres
Store
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/langgraphchannelsDeltaChannel
Classā—Since v0.3

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.

Copy
class DeltaChannel

Beta. The API and on-disk representation may change in future releases. Threads written with DeltaChannel today are expected to remain readable, but the surrounding contract (getDeltaChannelHistory, the DeltaSnapshot blob shape, the counters_since_delta_snapshot metadata field) is not yet stable.

Example

Copy
import { Annotation } from "@langchain/langgraph";
import { DeltaChannel, messagesDeltaReducer } from "@langchain/langgraph";

const State = Annotation.Root({
  messages: Annotation<BaseMessage[]>({
    reducer: () => [], // ignored; DeltaChannel is supplied below
  }),
});

Constructors

constructor
constructor

Properties

property
initialValueFactory: () => ValueType
property
lc_graph_name: string

The name of the channel.

property
reducer: DeltaReducer<ValueType, UpdateType>
property
snapshotFrequency: number
property
UpdateType: OverwriteOrValue<ValueType, UpdateType>
property
value: ValueType | undefined
property
ValueType: ValueType

Methods

method
checkpoint→ [Value, boolean] | undefined

Return a string representation of the channel's current state.

method
consume→ boolean

Mark the current value of the channel as consumed. By default, no-op. A channel can use this method to modify its state, preventing the value from being consumed again.

Returns True if the channel was updated, False otherwise.

method
equals→ boolean

Compare this channel with another channel for equality. Used to determine if two channels with the same key are semantically equivalent. Subclasses should override this method to provide a meaningful comparison.

method
finish→ boolean

Notify the channel that the Pregel run is finishing. By default, no-op. A channel can use this method to modify its state, preventing finish.

Returns True if the channel was updated, False otherwise.

method
fromCheckpoint→ LastValueAfterFinish<Value>

Return a new identical channel, optionally initialized from a checkpoint. Can be thought of as a "restoration" from a checkpoint which is a "snapshot" of the channel's state.

method
get→ Value

Return the current value of the channel.

method
isAvailable→ boolean

Return True if the channel is available (not empty), False otherwise. Subclasses should override this method to provide a more efficient implementation than calling get() and catching EmptyChannelError.

method
replayWrites

Apply ancestor writes oldest-to-newest via a single reducer call.

If any write is an Overwrite, the last one in the sequence acts as the reset point: its value becomes the new base and only writes after it are passed to the reducer.

method
update→ boolean

Update the channel's value with the given sequence of updates. The order of the updates in the sequence is arbitrary. This method is called by Pregel for all channels at the end of each step. If there are no updates, it is called with an empty sequence.

Raises InvalidUpdateError if the sequence of updates is invalid. Returns True if the channel was updated, False otherwise.

View source on GitHub