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/langgraphindexDeltaChannel
Class●Since v0.3

DeltaChannel

Copy
class DeltaChannel

Constructors

Properties

Methods

View source on GitHub

Example

constructor
constructor
property
initialValueFactory: () => ValueType
property
lc_graph_name: string
property
reducer: DeltaReducer<ValueType, UpdateType>
property
snapshotFrequency: number
property
UpdateType: OverwriteOrValue<ValueType, UpdateType>
property
value: ValueType | undefined
property
ValueType: ValueType
method
checkpoint→ [Value, boolean] | undefined
method
consume→ boolean
method
equals→ boolean
method
finish→ boolean
method
fromCheckpoint→ LastValueAfterFinish<Value>
method
get→ Value
method
isAvailable→ boolean
method
replayWrites
method
update→ boolean

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.

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.

The name of the channel.

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

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.

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.

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.

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.

Return the current value of the channel.

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.

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.

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.

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
  }),
});