This commit is contained in:
Sydney Runkle
2026-04-22 17:30:22 -04:00
parent 325cb42f19
commit 2e7edb2b60
7 changed files with 88 additions and 62 deletions
@@ -8,6 +8,7 @@ from typing import Any, cast
from langchain_core.runnables import RunnableConfig
from langgraph.checkpoint.base import (
DELTA_SENTINEL,
WRITES_IDX_MAP,
ChannelVersions,
Checkpoint,
@@ -446,8 +447,6 @@ class PostgresSaver(BasePostgresSaver):
including its configuration, metadata, parent checkpoint (if any),
and pending writes.
"""
from langgraph.checkpoint.base import DELTA_SENTINEL
channel_values = self._load_blobs(value["channel_values"])
if any(v is DELTA_SENTINEL for v in channel_values.values()):
cp_config = cast(
@@ -402,12 +402,7 @@ class AsyncPostgresSaver(BasePostgresSaver):
cur: Any,
) -> list[Any]:
"""Async version of _get_channel_writes_cur — see sync version for rationale."""
try:
from langgraph.types import (
Overwrite, # type: ignore[import-untyped,import-not-found]
)
except ImportError:
Overwrite = None # type: ignore[assignment]
from langgraph.types import Overwrite # type: ignore[import-untyped]
await cur.execute(
"SELECT checkpoint_id, parent_checkpoint_id FROM checkpoints "
@@ -440,7 +435,7 @@ class AsyncPostgresSaver(BasePostgresSaver):
for type_tag, blob in writes_by_cp.get(cid, []):
val = self.serde.loads_typed((type_tag, blob))
collected.append(val)
if Overwrite is not None and isinstance(val, Overwrite):
if isinstance(val, Overwrite):
collected.reverse()
return collected
collected.reverse()
@@ -235,13 +235,7 @@ class BasePostgresSaver(BaseCheckpointSaver[str]):
1. Fetch all (checkpoint_id, parent_checkpoint_id) for the thread.
2. Walk ancestry in Python, then fetch writes with a plain ANY() filter.
"""
# Lazy import: mirrors the Send pattern in the serializer.
try:
from langgraph.types import (
Overwrite, # type: ignore[import-untyped,import-not-found]
)
except ImportError:
Overwrite = None # type: ignore[assignment]
from langgraph.types import Overwrite # type: ignore[import-untyped]
cur.execute(
"SELECT checkpoint_id, parent_checkpoint_id FROM checkpoints "
@@ -274,7 +268,7 @@ class BasePostgresSaver(BaseCheckpointSaver[str]):
for type_tag, blob in writes_by_cp.get(cid, []):
val = self.serde.loads_typed((type_tag, blob))
collected.append(val)
if Overwrite is not None and isinstance(val, Overwrite):
if isinstance(val, Overwrite):
collected.reverse()
return collected
collected.reverse()