Garbage Collection Strategies for Agent Memory Stores
Agent memory grows. TTL, LRU, and typed eviction each fit different shapes. Why typed eviction beats simpler strategies for memory you actually want to keep long-term.
Agent memory grows. Without an eviction strategy, your store fills with stale conversations, superseded facts, and one-off observations the agent never references again. Cost climbs, recall slows, and the agent's reasoning gets noisier.
Three eviction patterns dominate, with very different fits.
TTL: the simplest, blunt instrument
Every memory carries an expiration date. After it expires, gone. Works fine for ephemeral context (today's conversation, this session's notes). Fails badly for things you actually want long-term ("this user is left-handed" should not expire because it was written six months ago).
Use when: all your memories have a natural expiration window.
LRU: cache logic applied to memory
Track access time on every memory. Evict the least-recently-used when storage gets tight. Better than TTL because frequently-recalled memories survive automatically. Worse than TTL because rarely-recalled-but-critical memories evict silently. The agent might never recall "this user has a peanut allergy" until the moment it matters, and by then LRU has dropped it.
Use when: recall frequency genuinely correlates with memory importance.
Typed eviction: the right shape for agent memory
Different memory types get different eviction policies. Conversation snippets expire after a session. Learned conventions never expire. Superseded facts evict on a long horizon (so lineage stays browsable for a few months). Confidence-weighted memories age out faster if low confidence.
This requires more upfront design (you have to type your memories) but gives you long-term behavior that does not silently lose what matters.
Use when: you care about the right memories surviving long enough to be useful.
What we recommend
- Type your memories at write time. Even three coarse types (session, learned, observed) is better than one bucket.
- Never silently drop high-confidence learned memories. Move them to a cold tier instead.
- Preserve lineage past the eviction window. A short summary of "this memory used to exist" is cheap and prevents the "where did that fact come from" mystery.
- Make eviction observable. Log what got dropped, why, and at what tier. You will need this when debugging the first time the agent forgets something it should have remembered.
Memnode supports typed eviction with cold-tier preservation as a first-class storage feature, because we think the alternative (silent loss) is the most common reason agents feel forgetful in production.