Skip to content

[ENH] Memory decay and relevance-based eviction in EMC #25

@OppaAI

Description

@OppaAI

Summary

EMC currently stores everything forever with no decay. Over time this creates "memory clutter" — irrelevant old episodes compete equally with important recent ones during search.

Current Behavior

All episodes have equal weight regardless of age or relevance. A trivial exchange from 2 years ago ranks the same as an important conversation from yesterday.

Proposed Enhancement

Add relevance-based decay to EMC search scoring:

def _score_episode(self, episode: dict, query_vec: list, now: datetime) -> float:
    # Semantic similarity
    semantic = _cosine(query_vec, json.loads(episode["embedding"]))
    
    # Time decay — older episodes score lower
    age_days = (now - datetime.fromisoformat(episode["date"])).days
    decay = math.exp(-age_days / DECAY_HALF_LIFE)  # exponential decay
    
    return semantic * decay

Options:

  • Exponential decay — gradual fade, important things still surface if relevant
  • TTL-based — hard expiry after N days (too aggressive)
  • Access-based — episodes accessed frequently stay fresh (like human memory)
  • Importance threshold — only decay below a relevance threshold

Impact

  • Recent important memories rank higher naturally
  • Old trivial memories fade gracefully
  • More human-like memory behavior
  • Reduces "memory clutter" over years of use

Notes

  • Decay should be gentle — GRACE remembers important things forever
  • DECAY_HALF_LIFE should be configurable in mcc.yaml
  • Implement in M2 alongside SMC — the 11pm reflection is a natural point to apply decay scoring
  • Do NOT implement hard deletion — 1TB NVMe means storage is free, keep everything

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

Status

Todo

Relationships

None yet

Development

No branches or pull requests

Issue actions