Feature Request: Memory Importance Scoring and Automatic Memory Decay
Feature Request: Memory Importance Scoring and Automatic Memory Decay
Problem
As Leon’s memory grows, older and less relevant memories can accumulate over time. This may reduce retrieval quality, increase storage usage, and make context selection less effective.
Currently, all memories are treated similarly, even though some memories are far more important than others.
Proposed Solution
Introduce a memory scoring system that tracks the importance of memories and gradually reduces the priority of rarely used memories.
Features
- Importance score for each memory.
- Automatic score increase when a memory is referenced.
- Automatic score decay over time.
- User-pinned memories that never decay.
- Memory cleanup suggestions.
Example Memory Structure
interface Memory { id: string; content: string; createdAt: Date; lastAccessedAt: Date; importanceScore: number; pinned: boolean; }
Example Decay Function
function updateImportance(memory: Memory): number { const daysSinceAccess = (Date.now() - memory.lastAccessedAt.getTime()) / (1000 * 60 * 60 * 24); return Math.max( 0, memory.importanceScore - daysSinceAccess * 0.01 ); }
Retrieval Strategy
When selecting memories:
const rankedMemories = memories.sort( (a, b) => b.importanceScore - a.importanceScore );
Only the highest-ranked memories would be sent to the LLM context window.
Benefits
- Better context relevance.
- Reduced memory clutter.
- Improved long-term scalability.
- More human-like memory behavior.
- Lower token usage.
Additional Notes
This feature aligns with Leon’s long-term goal of becoming a capable personal AI assistant while maintaining efficient memory management and strong user control.
Source: leon-ai/leon