Open
Description
1. Overview:
Provide an integration with Redis to enable fast, in-memory storage (with optional persistence) for agent memory components, such as conversational history or working memory state. Leveraging Redis can significantly speed up memory retrieval operations, making it suitable for scenarios requiring low latency or as a caching layer in front of slower persistent stores.
2. Goals:
- Implement a
MemoryStorage
adapter specifically for Redis. - Utilize a standard Node.js Redis client library (e.g.,
ioredis
orredis
). - Allow configuration of Redis connection details (connection string or host/port).
- Map conversational memory structures or working memory data to appropriate Redis data structures (e.g., Hashes for entries, Sorted Sets for ordering, simple Keys for values).
- Support efficient CRUD operations using Redis commands.
- Provide guidance on configuring Redis persistence (RDB/AOF) if long-term storage is desired via Redis itself.
- (Optional) Leverage Redis Stack (e.g., RediSearch with vector support) for storing and querying vector embeddings.
3. Proposed Architecture & Components:
RedisMemoryStorage
: A class implementing theMemoryStorage
interface. This class will:- Use a Node.js Redis client library (e.g.,
ioredis
). - Manage Redis connections.
- Translate memory operations into Redis commands (e.g.,
HSET
,HGETALL
,GET
,SET
,DEL
,ZADD
,ZRANGE
). - Handle serialization/deserialization of complex objects stored in Redis.
- Use a Node.js Redis client library (e.g.,
MemoryManager
Integration: ModifyMemoryManager
to accept and use theRedisMemoryStorage
adapter.- Configuration: Extend agent or global configuration to include Redis connection details.
- Data Modeling Guidance: Document recommended ways to structure agent memory data within Redis (e.g., key naming conventions, using Hashes per conversation entry).
4. Affected Core Modules:
MemoryManager
: Needs to support the newRedisMemoryStorage
adapter.Agent Options
/ Configuration: Needs to accommodate Redis connection settings.- Requires adding a Redis client library (e.g.,
ioredis
,redis
) as a dependency (likely optional).
5. Acceptance Criteria (Initial MVP):
- Users can configure
voltagent
to use a Redis instance for storing conversational history via connection parameters. - Basic agent conversation data (e.g., input/output per entry) is saved to Redis (e.g., using Hashes with keys like
history:<conversationId>:<entryId>
). - Conversation history can be retrieved from Redis based on
conversationId
. - Documentation provides basic setup instructions and connection examples.
- The integration uses a standard Redis client library.
6. Potential Challenges & Considerations:
- Data Modeling: Effectively representing potentially complex, nested memory structures in Redis key-value/hash formats.
- Memory Limits: Redis is typically memory-bound; storing very large or numerous conversation histories can consume significant RAM.
- Persistence Configuration: Users need to understand and configure Redis's RDB/AOF persistence mechanisms if durable storage is required.
- Suitability: Redis might be better suited as a cache or for short-term/working memory rather than the sole persistent store for extensive historical data compared to disk-based databases.
- Querying: Complex querying beyond simple key lookups or range scans can be less straightforward than SQL.
- Vector Search: Integrating with Redis Stack's vector search requires specific setup and commands.