Represents a state field backed by a DeltaChannel.
Unlike ReducedValue (which stores the full accumulated value in every
checkpoint blob via BinaryOperatorAggregate), a DeltaValue field persists
only per-step deltas (plus periodic snapshots) and reconstructs its state on
read by replaying ancestor writes through a batch reducer. This avoids
re-serializing large accumulators (e.g. long message histories) at every step.
class DeltaValueBeta. The on-disk representation backing DeltaChannel may change in
future releases.
import { z } from "zod";
import { StateSchema, DeltaValue } from "@langchain/langgraph";
const State = new StateSchema({
history: new DeltaValue(z.array(z.string()).default(() => []), {
inputSchema: z.string(),
reducer: (current, writes) => [...current, ...writes],
}),
});The schema used to validate reducer inputs. Defaults to valueSchema when
not specified explicitly.
Represents the type that may be provided as input on each update.
The batch reducer that folds a list of incoming writes into the current accumulated value.
Snapshot cadence forwarded to the underlying DeltaChannel.
The schema that describes the type of value stored in state (after reduction). Its default (if any) seeds the channel's initial value.
Represents the value stored after all reductions.