-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Feature: Redis Session Management #1247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@seratch @rm-openai would you mind taking a look? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a few general comments. I think supporting redis is a great addition for many developers. I would like @rm-openai to make the final decision on whether we should have this though!
docs/sessions.md
Outdated
### Redis memory | ||
|
||
```python | ||
from agents.memory.providers.redis import RedisSession |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
placing redis module in a sub package makes sense a lot
Add Redis Session Support and Restructure Memory Module
Context
I've fully switched to OpenAI Agents SDK at my company and I was looking for a distributed-systems friendly session management mechanism. I wasn't sure at the beginning if creating a
RedisSession
would defeat the "lightweight" purpose of OpenAI Agents SDK, so initially I've published openai-agents-redis on PyPi. It follows theSession
protocol and works quite similarly toSQLLiteSession
- but withredis
as the backend.Since I think the community would benefit from having this additional option for session management, I'm creating this PR - which incorporates the work I've done to support Redis for session management within OpenAI Agents SDK.
🚀 Overview
This PR introduces Redis-based session storage for the OpenAI Agents SDK and restructures the memory module for better organization and extensibility. The changes provide developers with a distributed, scalable alternative to SQLite sessions while maintaining full backward compatibility.
🎯 Key Features
✨ New Redis Session Implementation
RedisSession
: Full-featured Redis-based session storage with TTL supportRedisSessionManager
: Connection pooling and session management🏗️ Memory Module Restructuring
agents.memory.providers
📁 Changes Summary
New Files
src/agents/memory/providers/redis.py
- Redis session implementation (345 lines)src/agents/memory/providers/sqlite.py
- Extracted SQLite session (278 lines)src/agents/memory/providers/__init__.py
- Provider module initializationtests/test_redis_session.py
- Comprehensive test suite (553 lines, 33 tests)Modified Files
src/agents/memory/__init__.py
- Updated exports for new structuresrc/agents/memory/session.py
- Cleaned up to contain only protocol definitionsdocs/sessions.md
- Documentation updatepyproject.toml
- Added Redis dependency🔧 Technical Implementation
Redis Session Features
Key Capabilities
🧪 Testing
Test Coverage (33 tests)
RedisSession
classRedisSessionManager
classTest Features
Test Results
$ uv run pytest tests/test_redis_session.py -v ============================== 33 passed in 0.07s ==============================
📚 Documentation Updates
sessions.md
🔮 Future Considerations
This provider-based architecture enables:
📋 Checklist