Skip to content

Commit f383bff

Browse files
committed
feat: improve Redis session example with session clearing
- Add session.clear_session() at start of redis_session_example.py for clean demonstrations - Update docstring to explain session clearing behavior and production considerations - Prevents confusion from accumulated data across multiple example runs - Ensures consistent, predictable example behavior This addresses potential user confusion when running examples multiple times, as Redis sessions persist data between runs by design.
1 parent 583286b commit f383bff

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

examples/memory/redis_session_example.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
44
This example shows how to use Redis-backed session memory to maintain conversation
55
history across multiple agent runs with persistence and scalability.
6+
7+
Note: This example clears the session at the start to ensure a clean demonstration.
8+
In production, you may want to preserve existing conversation history.
69
"""
710

811
import asyncio
@@ -39,6 +42,10 @@ async def main():
3942

4043
print("Connected to Redis successfully!")
4144
print(f"Session ID: {session_id}")
45+
46+
# Clear any existing session data for a clean start
47+
await session.clear_session()
48+
print("Session cleared for clean demonstration.")
4249
print("The agent will remember previous messages automatically.\n")
4350

4451
# First turn

0 commit comments

Comments
 (0)