From e2d7efb34f242e854868d7ef83b949d9363ec091 Mon Sep 17 00:00:00 2001 From: Giles Odigwe Date: Wed, 18 Feb 2026 20:49:56 -0800 Subject: [PATCH 1/2] REDIS URL fix --- .../redis_chat_message_store_session.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/python/samples/02-agents/conversations/redis_chat_message_store_session.py b/python/samples/02-agents/conversations/redis_chat_message_store_session.py index f54edd8170..8a70768afc 100644 --- a/python/samples/02-agents/conversations/redis_chat_message_store_session.py +++ b/python/samples/02-agents/conversations/redis_chat_message_store_session.py @@ -8,6 +8,10 @@ from agent_framework.openai import OpenAIChatClient from agent_framework.redis import RedisHistoryProvider +# Default Redis URL for local Redis Stack. +# Override via the REDIS_URL environment variable for remote or authenticated instances. +REDIS_URL = os.getenv("REDIS_URL", "redis://localhost:6379") + """ Redis History Provider Session Example @@ -24,7 +28,7 @@ async def example_manual_memory_store() -> None: # Create Redis history provider redis_provider = RedisHistoryProvider( source_id="redis_basic_chat", - redis_url="redis://localhost:6379", + redis_url=REDIS_URL, ) # Create agent with Redis history provider @@ -62,7 +66,7 @@ async def example_user_session_management() -> None: # Create Redis history provider for specific user session redis_provider = RedisHistoryProvider( source_id=f"redis_{user_id}", - redis_url="redis://localhost:6379", + redis_url=REDIS_URL, max_messages=10, # Keep only last 10 messages ) @@ -103,7 +107,7 @@ async def example_conversation_persistence() -> None: print("--- Phase 1: Starting conversation ---") redis_provider = RedisHistoryProvider( source_id="redis_persistent_chat", - redis_url="redis://localhost:6379", + redis_url=REDIS_URL, ) agent = OpenAIChatClient().as_agent( @@ -152,7 +156,7 @@ async def example_session_serialization() -> None: redis_provider = RedisHistoryProvider( source_id="redis_serialization_chat", - redis_url="redis://localhost:6379", + redis_url=REDIS_URL, ) agent = OpenAIChatClient().as_agent( @@ -194,7 +198,7 @@ async def example_message_limits() -> None: # Create provider with small message limit redis_provider = RedisHistoryProvider( source_id="redis_limited_chat", - redis_url="redis://localhost:6379", + redis_url=REDIS_URL, max_messages=3, # Keep only 3 most recent messages ) @@ -229,7 +233,7 @@ async def main() -> None: print("Redis History Provider Examples") print("=" * 50) print("Prerequisites:") - print("- Redis server running on localhost:6379") + print("- Redis server running (set REDIS_URL env var or default localhost:6379)") print("- OPENAI_API_KEY environment variable set") print("=" * 50) From 019ba7afe325c855d2db4729286c7b92f278c6f6 Mon Sep 17 00:00:00 2001 From: Giles Odigwe Date: Wed, 18 Feb 2026 20:56:47 -0800 Subject: [PATCH 2/2] copilot fix --- .../conversations/redis_chat_message_store_session.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/samples/02-agents/conversations/redis_chat_message_store_session.py b/python/samples/02-agents/conversations/redis_chat_message_store_session.py index 8a70768afc..221ef158e2 100644 --- a/python/samples/02-agents/conversations/redis_chat_message_store_session.py +++ b/python/samples/02-agents/conversations/redis_chat_message_store_session.py @@ -8,10 +8,6 @@ from agent_framework.openai import OpenAIChatClient from agent_framework.redis import RedisHistoryProvider -# Default Redis URL for local Redis Stack. -# Override via the REDIS_URL environment variable for remote or authenticated instances. -REDIS_URL = os.getenv("REDIS_URL", "redis://localhost:6379") - """ Redis History Provider Session Example @@ -20,6 +16,10 @@ with Redis as the backend data store. """ +# Default Redis URL for local Redis Stack. +# Override via the REDIS_URL environment variable for remote or authenticated instances. +REDIS_URL = os.getenv("REDIS_URL", "redis://localhost:6379") + async def example_manual_memory_store() -> None: """Basic example of using Redis history provider."""