Memory System
The memory system provides hierarchical storage for conversations, knowledge, and agent state. It enables agents to maintain context, learn from interactions, and build persistent knowledge. For conceptual overview, see Memory and State. For runtime architecture, see Runtime Core.Memory Types
Core Memory Types
Memory Interface
State Management
State Structure
State represents the agent’s current understanding of context:State Composition Pipeline
Memory Operations
Creating Memories
Searching Memories
Memory Retrieval
Embeddings and Similarity
Creating Embeddings
Similarity Search
Facts and Knowledge
Fact Extraction
Facts are automatically extracted from conversations:Fact Management
Relationships
Relationship Storage
Managing Relationships
State Cache
Cache Architecture
The runtime maintains an in-memory cache for composed states:Cache Management
Document Storage
Document Memory
Document Operations
Memory Cleanup
Automatic Cleanup
Manual Cleanup
Memory Optimization
Indexing Strategies
Batch Operations
Memory Compression
Best Practices
Memory Design
- Type Selection: Use appropriate memory types for different data
- Embedding Strategy: Generate embeddings for searchable content
- Metadata Usage: Store relevant metadata for filtering
- Relationship Tracking: Maintain entity relationships
- Fact Extraction: Extract and store facts from conversations
Performance
- Indexing: Create appropriate database indexes
- Batch Operations: Use batch operations for multiple items
- Caching: Cache frequently accessed memories
- Cleanup: Implement regular cleanup routines
- Compression: Compress old data to save space
Data Integrity
- Validation: Validate memory content before storage
- Deduplication: Prevent duplicate facts and relationships
- Consistency: Maintain referential integrity
- Versioning: Track memory updates and changes
- Backup: Regular backup of critical memories