From 77f8f4948c81ca1bd8deed70a4ddc054aa9bafa8 Mon Sep 17 00:00:00 2001 From: Sydney Runkle Date: Fri, 17 Apr 2026 14:18:09 -0400 Subject: [PATCH] feat(checkpoint): add DiffDelta and DiffChainValue protocol types Co-Authored-By: Claude Sonnet 4.6 --- .../langgraph/checkpoint/base/__init__.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/libs/checkpoint/langgraph/checkpoint/base/__init__.py b/libs/checkpoint/langgraph/checkpoint/base/__init__.py index 33495d5e3..40a73bed5 100644 --- a/libs/checkpoint/langgraph/checkpoint/base/__init__.py +++ b/libs/checkpoint/langgraph/checkpoint/base/__init__.py @@ -1,6 +1,7 @@ from __future__ import annotations import copy +import dataclasses import logging from collections.abc import AsyncIterator, Collection, Iterator, Mapping, Sequence from typing import ( # noqa: UP035 @@ -28,6 +29,24 @@ from langgraph.checkpoint.serde.types import ( V = TypeVar("V", int, float, str) PendingWrite = tuple[str, str, Any] + + +@dataclasses.dataclass +class DiffDelta: + """Returned by DiffChannel.checkpoint(). Represents one step's writes.""" + + delta: list[Any] + prev_version: str | None # version of previous diff blob; None = chain root + + +@dataclasses.dataclass +class DiffChainValue: + """Passed to DiffChannel.from_checkpoint(). Assembled by saver _load_blobs().""" + + base: list[Any] | None # starting accumulated value; None = start from empty + deltas: list[list[Any]] # per-step write-sets, ordered oldest → newest + + logger = logging.getLogger(__name__)