From f41dfb292c5b0198aee624295fdf1920b8292ce9 Mon Sep 17 00:00:00 2001 From: Sydney Runkle Date: Tue, 21 Apr 2026 09:27:22 -0400 Subject: [PATCH] feat(checkpoint): DeltaValue uses prev_checkpoint_id; add get_channel_blob stubs --- .../langgraph/checkpoint/base/__init__.py | 32 +++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/libs/checkpoint/langgraph/checkpoint/base/__init__.py b/libs/checkpoint/langgraph/checkpoint/base/__init__.py index cbbfe74ed..2fd24fa65 100644 --- a/libs/checkpoint/langgraph/checkpoint/base/__init__.py +++ b/libs/checkpoint/langgraph/checkpoint/base/__init__.py @@ -36,12 +36,12 @@ class DeltaValue: """Returned by DeltaChannel.checkpoint(). Represents one step's writes.""" delta: list[Any] - prev_version: str | None # version of previous diff blob; None = chain root + prev_checkpoint_id: str | None # ID of checkpoint containing previous blob; None = chain root @dataclasses.dataclass class DeltaChainValue: - """Passed to DeltaChannel.from_checkpoint(). Assembled by saver _load_blobs().""" + """Passed to DeltaChannel.from_checkpoint(). Assembled by the pregel layer.""" base: list[Any] | None # starting accumulated value; None = start from empty deltas: list[list[Any]] # per-step write-sets, ordered oldest → newest @@ -476,6 +476,34 @@ class BaseCheckpointSaver(Generic[V]): """ raise NotImplementedError + def get_channel_blob( + self, + thread_id: str, + checkpoint_ns: str, + checkpoint_id: str, + channel: str, + ) -> Any: + """Look up a single channel blob by checkpoint ID + channel name. + + Returns NotImplemented if this saver does not support efficient + per-channel-version blob lookup. The pregel layer will fall back to + get_tuple() traversal in that case. + + Savers with a dedicated blob store (InMemorySaver, PostgresSaver) + should override this for O(1) performance. + """ + return NotImplemented + + async def aget_channel_blob( + self, + thread_id: str, + checkpoint_ns: str, + checkpoint_id: str, + channel: str, + ) -> Any: + """Async version of get_channel_blob.""" + return NotImplemented + def get_next_version(self, current: V | None, channel: None) -> V: """Generate the next version ID for a channel.