Skip to content

Commit c9c6e25

Browse files
committed
Mirror the Postgres implementation more accurately
1 parent 19f2f22 commit c9c6e25

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

langgraph/checkpoint/redis/__init__.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,18 +79,15 @@ def list(
7979
filter_expression = []
8080
if config:
8181
thread_id = config["configurable"]["thread_id"]
82-
checkpoint_ns = config["configurable"].get("checkpoint_ns", "")
82+
checkpoint_ns = config["configurable"].get("checkpoint_ns")
8383
checkpoint_id = get_checkpoint_id(config)
8484
filter_expression.append(Tag("thread_id") == thread_id)
8585

86-
# Following the Postgres implementation, we only want to filter by
87-
# checkpoint_ns if it's set. This is slightly different than the
88-
# get_tuple() logic, where we always query for checkpoint_ns.
89-
if checkpoint_ns:
86+
# Reproducing logic from the Postgres implementation.
87+
if checkpoint_ns is not None:
9088
filter_expression.append(Tag("checkpoint_ns") == checkpoint_ns)
91-
# We want to find all checkpoints for the thread matching the other
92-
# filters, with any checkpoint_id.
93-
filter_expression.append(Tag("checkpoint_id") == checkpoint_id)
89+
if checkpoint_id:
90+
filter_expression.append(Tag("checkpoint_id") == checkpoint_id)
9491

9592
if filter:
9693
for k, v in filter.items():
@@ -267,6 +264,7 @@ def get_tuple(self, config: RunnableConfig) -> Optional[CheckpointTuple]:
267264
checkpoint_id = get_checkpoint_id(config)
268265
checkpoint_ns = config["configurable"].get("checkpoint_ns", "")
269266

267+
# Reproducing logic from the Postgres implementation.
270268
if checkpoint_id:
271269
checkpoint_filter_expression = (
272270
(Tag("thread_id") == thread_id)

0 commit comments

Comments
 (0)