Expand description
Memory decay & forgetting (C3, v0.22.1 §S4): TTL + importance-driven consolidation.
Human memory fades; an agent’s memory should too, or stale and weak memories
silently pollute every future prompt. C3 layers a lightweight decay policy on top of
super::file_memory::FileMemoryStore:
- Recency wins: every access (remember/recall) stamps
last_access_at. A memory that is read frequently stays alive; one that goes idle long enough is forgotten. - Importance floor: each memory carries an
importancein[0, 1]. Weak memories (importance < min_importance) that have gone quiet pastweak_graceare pruned even before the full TTL — they are not earning their keep. - Explicit consolidation: decay never happens on a hot read path. The caller runs
ForgettingMemory::consolidate(e.g. between turns or on a schedule), which atomically drops expired/weak memories and persists the ledger.
The time source is injected (now: SystemTime), making every rule pure and unit-testable
without sleeping. The metadata ledger is persisted as .memory.json inside the store
root, so importance and timestamps survive restarts.
Structs§
- Forget
Config - Decay policy configuration.
- Forgetting
Memory - A decaying, file-backed memory store.