Suppose a hypothetical assistant stores facts from every conversation. After several months it retrieves outdated preferences, duplicated summaries, temporary project details, and an early mistake the user later corrected. More memory has made responses less reliable rather than more personalized.
Our agent memory gets noisier over time. How would you design the memory lifecycle?
Memory is not a transcript with vector search attached. It is derived product data with decisions about admission, provenance, scope, retrieval, correction, expiration, and deletion.
Why the common answer is incomplete
Most candidates answer: “Put every conversation into a vector database and retrieve the most similar messages.”
Similarity does not determine whether a memory is true, current, authorized, or relevant to the present task. Raw conversations contain speculation, third-party information, and temporary context. A semantically similar old statement can override a more recent correction. Storing everything also increases privacy exposure and makes user deletion difficult.
A production memory system needs a controlled write path and an explicit lifecycle for every memory type.
A production approach
1. Define memory classes and their purpose
Separate durable user preferences, organization facts, episodic task history, temporary working state, and procedural instructions. Define which product behavior each class enables. Working state may last one task, while an explicitly saved preference can persist across sessions. Do not create a generic memory bucket whose retention and trust depend only on embedding similarity.
2. Apply an admission policy before writing
Store only information that is useful beyond the current context and allowed by product policy. Prefer explicit user requests such as “remember this” for sensitive or durable preferences. Use deterministic filters for secrets, authentication data, and prohibited categories. A model can propose a memory candidate, but application policy decides whether it is stored and under which scope.
3. Preserve provenance and confidence
Attach tenant, user, source conversation, message identifiers, creation time, writer version, and evidence to every memory. Distinguish user-stated facts from model inferences. Inferred memory should have lower trust and often require confirmation before affecting important decisions. Provenance lets the product explain, correct, rebuild, or delete memory when the source changes.
4. Resolve updates instead of appending contradictions
Use stable keys for facts such as preferred language or current project when the domain supports them. A new confirmed value supersedes the previous value while preserving audit history. For unstructured memories, detect potential conflicts and retrieve both for resolution. Ranking by recency alone is insufficient when an old durable policy should outlive a newer temporary exception.
5. Retrieve by scope, validity, and relevance
Filter by authenticated user, tenant, memory class, active time window, and deletion state before semantic ranking. Combine recency, explicitness, source trust, and relevance rather than using vector score alone. Limit the number and token size of memories entering context. When confidence is low or memories conflict, ask the user instead of silently choosing one.
6. Consolidate without losing traceability
Merge repeated episodic memories into a structured summary when doing so reduces noise. Record which source memories contributed and which consolidation version created the result. Keep source pointers until retention permits deletion. If consolidation changes meaning or loses a correction, the system must be able to invalidate and rebuild it from surviving evidence.
7. Expire, decay, and review memory deliberately
Give temporary state a short time-to-live and durable preferences a review or confirmation policy. Decay retrieval priority for stale inferred memories, but do not use decay as a substitute for deletion. Product teams should define retention from user value, privacy requirements, and correction cost. A memory that is never retrieved still creates data-governance obligations.
8. Support user control and complete deletion
Let users inspect, correct, forget, or disable memory. Propagate deletion to the primary store, vector index, caches, summaries, and backups according to policy. Tombstone deleted items so delayed indexing events cannot resurrect them. Test account and tenant deletion end to end; a UI confirmation is meaningless if derived indexes retain the content.
Engineering trade-offs
Explicit confirmation improves accuracy and consent but adds friction. Automatic memory feels seamless while increasing false facts and privacy risk. Structured facts are easier to update and filter; unstructured episodes preserve nuance but are harder to resolve. Long retention improves personalization while increasing stale-state and compliance costs.
Consolidation reduces context and duplicate retrieval but introduces another probabilistic transformation. Keeping source events improves auditability and rebuilds while consuming storage. The right balance depends on whether memory is a convenience feature or a dependency for high-impact actions.
Common mistakes
- Storing every message because storage is inexpensive.
- Treating semantic similarity as proof that a memory is current and true.
- Mixing one user’s memory with tenant-wide facts.
- Storing model inferences as if the user stated them.
- Appending corrections without superseding the old value.
- Deleting the primary row while leaving vector and cache copies.
- Allowing memory to authorize actions or access resources.
Failure handling and observability
Log memory candidates, admission decisions, provenance, scope, supersession, retrieval features, conflict detection, and deletion propagation without exposing sensitive values in general logs. Monitor write acceptance, retrieval usefulness, stale-memory corrections, conflicting facts, age distribution, consolidation failures, and deletion completion. Sample cases where users correct the assistant and add them to memory evaluations.
If the memory service is unavailable, continue the current task without personalization when safe and do not invent remembered facts. If a retrieved memory conflicts with the current user statement, prefer the authenticated current instruction and schedule correction. If deletion partially fails, keep the memory globally suppressed until every derived store confirms removal. Fail closed on cross-tenant scope uncertainty.
Interview insight
The interviewer is not testing whether you know a vector database. They are testing whether you can manage derived state over time. A staff-level answer treats memory as a lifecycle with admission, provenance, conflict resolution, bounded retrieval, user control, and deletion—not as an unlimited archive of conversation text.