This guide explains how ATOM's chat interface is connected with the memory system, implementing short-term and long-term memory capabilities similar to a human brain. The memory system uses LanceDB for vector storage and provides context-aware responses based on conversation history.
ATOM Memory System
├── Short-Term Memory (Working Memory)
│ ├── Session-based storage
│ ├── Recent conversation context
│ ├── Automatic decay and cleanup
│ └── In-memory storage for performance
├── Long-Term Memory (Persistent Storage)
│ ├── LanceDB vector database
│ ├── Semantic search capabilities
│ ├── Importance-based retention
│ └── Cross-session persistence
├── User Pattern Recognition
│ ├── Behavior pattern detection
│ ├── Workflow usage patterns
│ ├── Communication preferences
│ └── Confidence-based pattern scoring
└── Context Retrieval Engine
├── Semantic similarity search
├── Relevance scoring
├── Context summarization
└── Memory access optimization
-
Short-Term Memory
- Stores recent conversations (last 50 messages per session)
- Session-based with automatic timeout (60 minutes)
- Fast access for immediate context
- Automatic cleanup on session end
-
Long-Term Memory
- Persistent storage in LanceDB
- Vector embeddings for semantic search
- Importance-based retention (threshold: 0.7)
- Cross-session availability
-
User Patterns
- Workflow usage patterns
- Active hours detection
- Communication preferences
- Automated behavior learning
import { useChatMemory } from '../hooks/useChatMemory';
const {
// State
memories,
memoryContext,
memoryStats,
isLoading,
error,
// Actions
storeMemory,
getMemoryContext,
clearSessionMemory,
refreshMemoryStats,
// Utilities
hasRelevantContext,
contextRelevanceScore
} = useChatMemory({
userId: 'user123',
sessionId: 'session456',
enableMemory: true,
autoStoreMessages: true,
contextWindow: 10
});import { EnhancedChatInterface } from '../components/chat/EnhancedChatInterface';
<EnhancedChatInterface
userId="user123"
sessionId="session456"
enableMemory={true}
showMemoryControls={true}
onWorkflowTrigger={handleWorkflow}
onVoiceCommand={handleVoice}
/>from chat_memory_service import ChatMemoryService, ConversationMemory
# Initialize service
memory_service = ChatMemoryService()
# Store conversation
memory = ConversationMemory(
user_id="user123",
session_id="session456",
role="user",
content="Schedule a meeting for tomorrow",
metadata={
"workflow_id": "wf_123",
"intent": "schedule_meeting",
"importance": 0.8
}
)
result = await memory_service.store_conversation(memory)POST /api/chat/memory/store- Store conversation memoryPOST /api/chat/memory/context- Get memory contextGET /api/chat/memory/history- Get conversation historyDELETE /api/chat/memory/session/{session_id}- Clear session memoryGET /api/chat/memory/stats- Get memory statisticsGET /api/chat/memory/health- Health check
-
Message Reception
- User sends message through chat interface
- Message is automatically stored in short-term memory
- Importance score is calculated (0-1 scale)
-
Context Retrieval
- Semantic search in long-term memory using LanceDB
- Pattern matching for user behavior
- Relevance scoring and ranking
-
Response Generation
- Context-aware response generation
- Memory-enhanced suggestions
- Pattern-based personalization
-
Memory Consolidation
- Important conversations moved to long-term storage
- User pattern updates
- Access count tracking
Memory importance is calculated based on:
- Workflow Relevance (+0.3): Messages related to workflows
- Question/Command (+0.2): User questions and commands
- Action Responses (+0.2): Assistant responses with actions
- Content Length (+0.1): Longer, more detailed content
The system automatically detects:
- Workflow Patterns: Frequently used workflows
- Time Patterns: Active hours and usage patterns
- Communication Styles: Preferred interaction methods
- Task Preferences: Common task types and platforms
# Default configuration
short_term_memory_size = 50
long_term_threshold = 0.7
similarity_threshold = 0.6
session_timeout_minutes = 60
pattern_detection_window = 7 * 24 * 60 * 60 # 1 weekThe system uses the existing LanceDB infrastructure:
- Table:
conversations - Embedding Dimension: 1536 (configurable)
- Search: Vector similarity with user filtering
- Storage: Persistent with automatic indexing
// Store a user message
await storeMemory({
userId: 'user123',
sessionId: 'session456',
role: 'user',
content: 'Can you help me schedule a team meeting?',
metadata: {
messageType: 'text',
intent: 'schedule_meeting',
importance: 0.8
}
});
// Get memory context for response
const context = await getMemoryContext('Can you help me schedule a team meeting?');
// Enhanced response using memory context
if (context.relevanceScore > 0.5) {
response = `I recall we discussed meetings before. ${response}`;
}// Check memory statistics
const stats = memoryStats;
console.log(`Short-term memories: ${stats.shortTermMemoryCount}`);
console.log(`User patterns: ${stats.userPatternCount}`);
// Clear session memory (e.g., on logout)
await clearSessionMemory();
// Manual memory management
await storeMemory({
userId: 'user123',
sessionId: 'session456',
role: 'assistant',
content: 'I created the workflow as requested',
metadata: {
workflowId: 'wf_789',
importance: 0.9
}
});-
LanceDB Unavailable
- System falls back to short-term memory only
- User patterns still work
- Graceful degradation
-
Memory Storage Failures
- Individual memory storage failures don't break the system
- Errors are logged but don't interrupt chat flow
- Automatic retry mechanisms
-
Session Timeouts
- Automatic cleanup of expired sessions
- Memory statistics reflect active sessions only
- No impact on long-term memory
- Memory health checks via
/api/chat/memory/health - Statistics tracking via
/api/chat/memory/stats - Error logging with detailed context
- Performance metrics for memory operations
-
Importance Scoring
- Set appropriate importance thresholds
- Balance between memory usage and relevance
- Monitor pattern detection accuracy
-
Session Management
- Use meaningful session IDs
- Implement proper session cleanup
- Consider user privacy requirements
-
Performance
- Limit context window size appropriately
- Use batch operations for multiple memories
- Monitor LanceDB performance
- User data isolation in memory storage
- Session-based memory separation
- Configurable data retention policies
- Compliance with privacy regulations
-
Memory Context Not Available
- Check LanceDB connectivity
- Verify user ID and session ID
- Check importance threshold settings
-
Pattern Detection Not Working
- Ensure sufficient conversation history
- Verify pattern detection window
- Check confidence thresholds
-
Performance Issues
- Monitor memory statistics
- Check LanceDB indexing
- Review context window size
- Memory health endpoint
- Detailed logging
- Statistics monitoring
- Context relevance scoring
-
Advanced Pattern Recognition
- Machine learning-based pattern detection
- Cross-user pattern analysis
- Predictive memory retrieval
-
Memory Compression
- Automatic summarization of similar memories
- Hierarchical memory organization
- Efficient storage strategies
-
Multi-modal Memory
- Integration with document memory
- Voice conversation memory
- Cross-platform memory unification
- Integration with workflow automation memory
- Connection with document processing pipeline
- Enhanced user modeling capabilities
- Advanced personalization features
For technical support or questions about memory integration:
- Check system logs for memory-related errors
- Verify LanceDB connectivity and configuration
- Review memory statistics for usage patterns
- Contact the development team for complex issues
Last Updated: 2025 Maintained by ATOM Development Team