From 94c0209229a61a20c45e3e806990a45a3b77fef2 Mon Sep 17 00:00:00 2001 From: Brian Sam-Bodden Date: Mon, 21 Jul 2025 15:28:00 -0700 Subject: [PATCH] fix: add async setup() method to AsyncRedisSaver (#74) Add async setup() method to AsyncRedisSaver that delegates to asetup() to match the canonical pattern used by PostgreSQL and SQLite checkpointers. This fixes the RuntimeWarning caused by calling the inherited sync setup() method from BaseRedisSaver, which called async create() methods without awaiting them. Maintains backward compatibility by keeping the existing asetup() method while providing the standard async setup() interface that users expect from LangGraph checkpointers. Fixes #74 --- langgraph/checkpoint/redis/aio.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/langgraph/checkpoint/redis/aio.py b/langgraph/checkpoint/redis/aio.py index 1eeecdf..f887fc8 100644 --- a/langgraph/checkpoint/redis/aio.py +++ b/langgraph/checkpoint/redis/aio.py @@ -152,6 +152,21 @@ async def asetup(self) -> None: # Detect cluster mode if not explicitly set await self._detect_cluster_mode() + async def setup(self) -> None: # type: ignore[override] + """Set up the checkpoint saver asynchronously. + + This method creates the necessary indices in Redis and detects cluster mode. + It MUST be called before using the checkpointer. + + This async method follows the canonical pattern used by PostgreSQL and SQLite + checkpointers in the LangGraph ecosystem. The type ignore is necessary because + the base class defines a sync setup() method, but async checkpointers require + an async setup() method to properly handle coroutines. + + Usage: await checkpointer.setup() + """ + await self.asetup() + async def _detect_cluster_mode(self) -> None: """Detect if the Redis client is a cluster client by inspecting its class.""" if self.cluster_mode is not None: