Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ litellm = ["litellm>=1.67.4.post1, <2"]
realtime = ["websockets>=15.0, <16"]
sqlalchemy = ["SQLAlchemy>=2.0", "asyncpg>=0.29.0"]
encrypt = ["cryptography>=45.0, <46"]
redis = ["redis>=6.4.0"]
redis = ["redis>=7"]
dapr = ["dapr>=1.16.0", "grpcio>=1.60.0"]

[dependency-groups]
Expand Down
8 changes: 1 addition & 7 deletions src/agents/extensions/memory/redis_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import json
import time
from typing import Any
from urllib.parse import urlparse

try:
import redis.asyncio as redis
Expand Down Expand Up @@ -96,11 +95,6 @@ def from_url(
"""
redis_kwargs = redis_kwargs or {}

# Parse URL to determine if we need SSL
parsed = urlparse(url)
if parsed.scheme == "rediss":
redis_kwargs.setdefault("ssl", True)

redis_client = redis.from_url(url, **redis_kwargs)
session = cls(session_id, redis_client=redis_client, **kwargs)
session._owns_client = True # We created the client, so we own it
Expand Down Expand Up @@ -261,7 +255,7 @@ async def ping(self) -> bool:
True if Redis is reachable, False otherwise.
"""
try:
await self._redis.ping()
await self._redis.ping() # type: ignore[misc] # Redis library returns Union[Awaitable[T], T] in async context
return True
except Exception:
return False
6 changes: 3 additions & 3 deletions tests/extensions/memory/test_redis_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,14 +492,14 @@ async def test_external_client_not_closed():
assert len(items) == 1

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

# Close the session
await session.close()

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

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

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

# Test 2: Internal client (should be closed)
# Create a session that owns its client
Expand Down
8 changes: 4 additions & 4 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.