optimizations i sure hope

This commit is contained in:
Sydney Runkle
2026-04-22 20:47:51 -04:00
parent 5b7fdf5655
commit acc7eda8c5
7 changed files with 192 additions and 184 deletions
@@ -15,6 +15,7 @@ from langgraph.checkpoint.base import (
CheckpointMetadata,
CheckpointTuple,
DeltaChannelWrites,
_overwrite_types,
get_checkpoint_id,
get_serializable_checkpoint_metadata,
)
@@ -402,7 +403,7 @@ class AsyncPostgresSaver(BasePostgresSaver):
cur: Any,
) -> list[Any]:
"""Async version of _get_channel_writes_cur — see sync version for rationale."""
from langgraph.types import Overwrite # type: ignore[import-untyped]
overwrite_types = _overwrite_types()
await cur.execute(
"SELECT checkpoint_id, parent_checkpoint_id FROM checkpoints "
@@ -435,7 +436,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 isinstance(val, Overwrite):
if isinstance(val, overwrite_types):
collected.reverse()
return collected
collected.reverse()
@@ -14,6 +14,7 @@ from langgraph.checkpoint.base import (
BaseCheckpointSaver,
ChannelVersions,
DeltaChannelWrites,
_overwrite_types,
get_checkpoint_id,
)
from langgraph.checkpoint.serde.types import TASKS
@@ -235,7 +236,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.
"""
from langgraph.types import Overwrite # type: ignore[import-untyped]
overwrite_types = _overwrite_types()
cur.execute(
"SELECT checkpoint_id, parent_checkpoint_id FROM checkpoints "
@@ -268,7 +269,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 isinstance(val, Overwrite):
if isinstance(val, overwrite_types):
collected.reverse()
return collected
collected.reverse()