From e338a4ec989dc0dc43e69d0a3b49ce9c96040f8a Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Tue, 27 Aug 2024 16:09:11 -0700 Subject: [PATCH] Fix filtering on ns --- .../langgraph/checkpoint/postgres/base.py | 3 ++- libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/utils.py | 3 ++- libs/checkpoint/langgraph/checkpoint/memory/__init__.py | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/libs/checkpoint-postgres/langgraph/checkpoint/postgres/base.py b/libs/checkpoint-postgres/langgraph/checkpoint/postgres/base.py index c0f723f9e..582206dd5 100644 --- a/libs/checkpoint-postgres/langgraph/checkpoint/postgres/base.py +++ b/libs/checkpoint-postgres/langgraph/checkpoint/postgres/base.py @@ -260,7 +260,8 @@ class BasePostgresSaver(BaseCheckpointSaver): if config: wheres.append("thread_id = %s ") param_values.append(config["configurable"]["thread_id"]) - if checkpoint_ns := config["configurable"].get("checkpoint_ns"): + checkpoint_ns = config["configurable"].get("checkpoint_ns") + if checkpoint_ns is not None: wheres.append("checkpoint_ns = %s") param_values.append(checkpoint_ns) diff --git a/libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/utils.py b/libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/utils.py index 0e1e06fcc..a8ceb496a 100644 --- a/libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/utils.py +++ b/libs/checkpoint-sqlite/langgraph/checkpoint/sqlite/utils.py @@ -70,7 +70,8 @@ def search_where( if config is not None: wheres.append("thread_id = ?") param_values.append(config["configurable"]["thread_id"]) - if checkpoint_ns := config["configurable"].get("checkpoint_ns"): + checkpoint_ns = config["configurable"].get("checkpoint_ns") + if checkpoint_ns is not None: wheres.append("checkpoint_ns = ?") param_values.append(checkpoint_ns) diff --git a/libs/checkpoint/langgraph/checkpoint/memory/__init__.py b/libs/checkpoint/langgraph/checkpoint/memory/__init__.py index 3d69165c0..372e5ba2f 100644 --- a/libs/checkpoint/langgraph/checkpoint/memory/__init__.py +++ b/libs/checkpoint/langgraph/checkpoint/memory/__init__.py @@ -210,7 +210,10 @@ class MemorySaver( config_checkpoint_id = get_checkpoint_id(config) if config else None for thread_id in thread_ids: for checkpoint_ns in self.storage[thread_id].keys(): - if config_checkpoint_ns and checkpoint_ns != config_checkpoint_ns: + if ( + config_checkpoint_ns is not None + and checkpoint_ns != config_checkpoint_ns + ): continue for checkpoint_id, (