mirror of
https://github.com/langchain-ai/langgraph.git
synced 2026-09-27 12:04:58 +02:00
optimizations i sure hope
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user