Zenaique

Design a decay policy for an agent that has been talking to one user for two years

Short answer·Hard·4.0 · 0·~3 min·Asked atAndurilPersistentTcs
Attempt it

After two years of daily use, an agent's memory store has 10,000+ facts about one user. Many are stale. Design a decay policy that keeps the store useful without losing important history.

Free · 2 AI evals / day
TL;DR

Score each memory on recency, frequency, and importance; demote (not delete) below threshold; treat episodic and semantic differently; exempt safety facts and user-set preferences entirely.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine a personal assistant who has worked with you for two years and now has filing cabinets full of notes about you. Some notes are still relevant (your coffee order, the people you work with). Some are very dated (where you parked your car in March 2024). Some are non-negotiable no matter how old (your allergies, your spouse's name). A good filing system moves dated notes from the active drawer into a basement archive, where you can still ask for them by name but they no longer clutter the top drawer. The non-negotiable ones stay pinned to the desk forever. Memory decay for an agent works the same way: demote the dated, keep the always-relevant, and never trash anything that might still matter.

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Two years of daily agent conversation is a memory-systems stress test that did not exist in production until recently. The store grows past any reasonable retrieval budget. The user expects the agent to still know what it learned about them. A naive cleanup pass either keeps everything (and the active store becomes useless) or evicts aggressively (and the user-facing failure mode is the agent forgetting something they expected it to remember).

The design space is multi-dimensional and the failure modes are sharp. This answer walks through the salience scoring, the demotion versus deletion decision, the differential decay by memory type, and the exemption list, and grounds each in what production systems (Zep, Mem0, Letta) actually do.

Why a single signal fails

Three single-signal designs and the failure each one creates.

Recency only. Evict memories not accessed in N days. Failure mode: a stable user preference held for two years and queried twice a year gets evicted. The user notices and complains.

Frequency only. Evict memories accessed fewer than K times. Failure mode: a safety-critical fact (allergy, medical condition) is referenced rarely but must never be lost. Or a high-frequency conversational tic accumulates score without being useful.

Importance only. Evict memories the model marked as low-importance at write time. Failure mode: importance flags are set at write time without knowing how the user will use the agent later; the model judges wrong and evicts something useful, or hoards everything labeled high-importance and the store still grows.

The robust design is a weighted combination of all three. None of the signals is individually sufficient; together they cover the failure modes.

si=αrecency(ti)+βfreq(ci)+γimportance(Ii)s_i = \alpha \cdot \text{recency}(t_i) + \beta \cdot \text{freq}(c_i) + \gamma \cdot \text{importance}(I_i)

The coefficients should be tuned per memory type. Episodic memories weight recency more heavily; semantic memories weight frequency and importance more heavily; safety memories ignore the score entirely (see exemption section).

Demotion, not deletion
Differential decay and the exemption list
Production references and operational details
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.

Real products, models, and research that use this idea.

  • Zep maintains a temporal knowledge graph in 2026 with fact-level timestamps, decay weights, and graph-walk retrieval; it is the closest production system to the decay design described here.
  • Mem0 in 2026 emphasizes deduplication and merging at write time rather than time-based decay; complementary to Zep's approach.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QHow would you decide which class a newly extracted memory belongs to (episodic, semantic, procedural)?
A

Use a small classifier at extract time. The Mem0 extractor already produces typed memories. For higher fidelity, run a second-pass model that takes the extracted fact and the source message and emits a type tag plus an importance flag. The classification only happens once per memory at write, so the cost is bounded.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Treating decay as a single time-based score. Recency alone evicts a stable preference the user has held for two years and queries about once a month.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • The three independent signals that should feed a decay score

  • Why demotion is preferred over deletion below threshold

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
Pick the most effective intervention when an agent's context grows by 8KB every iteration
MCQ·Medium