Skip to content

Build and run agents you can see, understand and trust.

fix(memory): fix the bug in redis memory that use bytes data as the message key (#1146)

DavdGaoba6a627de8f7
diff --git a/src/agentscope/memory/_working_memory/_redis_memory.py b/src/agentscope/memory/_working_memory/_redis_memory.py
index 8a3ebd4a4..9ec0b2a43 100644
--- a/src/agentscope/memory/_working_memory/_redis_memory.py
+++ b/src/agentscope/memory/_working_memory/_redis_memory.py
@@ -88,6 +88,7 @@ class RedisMemory(MemoryBase):
db=db,
password=password,
connection_pool=connection_pool,
+ decode_responses=True,
**kwargs,
)
@@ -559,9 +560,17 @@ class RedisMemory(MemoryBase):
await pipe.execute()
return updated_count
- async def close(self) -> None:
- """Close the Redis client connection."""
- await self._client.close()
+ async def close(self, close_connection_pool: bool | None = None) -> None:
+ """Close the Redis client connection.
+
+ Args:
+ close_connection_pool (`bool | None`, optional):
+ Decides whether to close the connection pool used by this
+ Redis client, overriding Redis.auto_close_connection_pool.
+ By default, let Redis.auto_close_connection_pool decide
+ whether to close the connection pool
+ """
+ await self._client.aclose(close_connection_pool=close_connection_pool)
async def __aenter__(self) -> "RedisMemory":
"""Enter the async context manager.