Skip to content

Handle missing config keys during checkpoint search #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 6, 2025
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Mirror the Postgres implementation more accurately
  • Loading branch information
abrookins committed Mar 5, 2025
commit c9c6e2559a39bdfdace830068019e91755651c13
14 changes: 6 additions & 8 deletions langgraph/checkpoint/redis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,15 @@ def list(
filter_expression = []
if config:
thread_id = config["configurable"]["thread_id"]
checkpoint_ns = config["configurable"].get("checkpoint_ns", "")
checkpoint_ns = config["configurable"].get("checkpoint_ns")
checkpoint_id = get_checkpoint_id(config)
filter_expression.append(Tag("thread_id") == thread_id)

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

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

# Reproducing logic from the Postgres implementation.
if checkpoint_id:
checkpoint_filter_expression = (
(Tag("thread_id") == thread_id)
Expand Down