Skip to content

Commit 05dc79d

Browse files
authored
fix: #2081 Redis SSL Connection Error with redis-py v7 (#2082)
1 parent 2c0f7c2 commit 05dc79d

File tree

4 files changed

+9
-15
lines changed

4 files changed

+9
-15
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ litellm = ["litellm>=1.67.4.post1, <2"]
4141
realtime = ["websockets>=15.0, <16"]
4242
sqlalchemy = ["SQLAlchemy>=2.0", "asyncpg>=0.29.0"]
4343
encrypt = ["cryptography>=45.0, <46"]
44-
redis = ["redis>=6.4.0"]
44+
redis = ["redis>=7"]
4545
dapr = ["dapr>=1.16.0", "grpcio>=1.60.0"]
4646

4747
[dependency-groups]

src/agents/extensions/memory/redis_session.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import json
2626
import time
2727
from typing import Any
28-
from urllib.parse import urlparse
2928

3029
try:
3130
import redis.asyncio as redis
@@ -96,11 +95,6 @@ def from_url(
9695
"""
9796
redis_kwargs = redis_kwargs or {}
9897

99-
# Parse URL to determine if we need SSL
100-
parsed = urlparse(url)
101-
if parsed.scheme == "rediss":
102-
redis_kwargs.setdefault("ssl", True)
103-
10498
redis_client = redis.from_url(url, **redis_kwargs)
10599
session = cls(session_id, redis_client=redis_client, **kwargs)
106100
session._owns_client = True # We created the client, so we own it
@@ -261,7 +255,7 @@ async def ping(self) -> bool:
261255
True if Redis is reachable, False otherwise.
262256
"""
263257
try:
264-
await self._redis.ping()
258+
await self._redis.ping() # type: ignore[misc] # Redis library returns Union[Awaitable[T], T] in async context
265259
return True
266260
except Exception:
267261
return False

tests/extensions/memory/test_redis_session.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,14 +492,14 @@ async def test_external_client_not_closed():
492492
assert len(items) == 1
493493

494494
# Verify client is working before close
495-
assert await shared_client.ping() is True
495+
assert await shared_client.ping() is True # type: ignore[misc] # Redis library returns Union[Awaitable[T], T] in async context
496496

497497
# Close the session
498498
await session.close()
499499

500500
# Verify the shared client is still usable after session.close()
501501
# This would fail if we incorrectly closed the external client
502-
assert await shared_client.ping() is True
502+
assert await shared_client.ping() is True # type: ignore[misc] # Redis library returns Union[Awaitable[T], T] in async context
503503

504504
# Should still be able to use the client for other operations
505505
await shared_client.set("test_key", "test_value")
@@ -781,7 +781,7 @@ async def test_close_method_coverage():
781781
await session1.close()
782782

783783
# Verify external client is still usable
784-
assert await external_client.ping() is True
784+
assert await external_client.ping() is True # type: ignore[misc] # Redis library returns Union[Awaitable[T], T] in async context
785785

786786
# Test 2: Internal client (should be closed)
787787
# Create a session that owns its client

uv.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)