All articles

Agent Memory Needs a Lifecycle, Not Just Retrieval

Agent memory needs provenance, temporal validity and deletion as well as retrieval. Separate evidence from facts, correction from erasure and recency from expiry.

A memory ledger links a reported Bristol move to the current city fact and a retained Leeds history, distinguishing recency from expiry and temporal invalidation from erasure.

Suppose a user says they live in Leeds in March, announces a move to Bristol in July, then asks for their local recycling rules. A similarity search can retrieve both addresses with equal confidence. If the later statement merely overwrites the earlier one, the agent can answer the current question but may forget when the old address applied. If the user later requests erasure, marking either statement obsolete accomplishes nothing by itself.

These are different operations on durable state. Retrieval chooses what enters the next prompt. Correction changes what the agent should believe. Temporal invalidation records when a claim stopped being true. Retention policy decides how long records may remain. Erasure removes personal data when required. A production memory layer needs all five, with explicit connections between them.

Raw episodes feed extraction into semantic facts linked back to their evidence. Bi-temporal validity and correction guide retrieval, while retention expiry and privacy erasure follow separate governance paths across primary and derived stores.
Retrieval produces a task-specific view of memory. Invalidation closes a fact’s validity interval; expiry applies retention policy; erasure propagates through evidence and derived records. None is a synonym for recency decay.

Keep evidence beside interpretation

An episodic record captures something that happened: a message, tool result or observation, tied to an actor and a time. A semantic fact is an interpretation derived from that evidence, such as a user’s city or dietary preference. Reflections and summaries sit still further from the original event. Treating them all as interchangeable text hides their different failure modes.

Generative Agents made this layered structure influential. Its memory stream stores natural-language observations with creation and last-access timestamps. Retrieval combines normalised recency, importance and relevance scores. When recent events pass an importance threshold, reflections synthesise higher-level claims and retain pointers to the records used as evidence. The mechanism prevents an ever-growing transcript from becoming the whole prompt, but a reflection remains generated interpretation rather than a new primary observation.

Zep separates raw episodes from semantic entities and relationships. Bidirectional links connect extracted facts to their source episodes so the system can traverse back for citation or quotation. That provenance is the basis for correction and audit. Preserve the source identifier, observed and ingestion timestamps, extraction version, and the purpose and access scope of each record. A summary without that lineage is difficult to challenge and harder to delete reliably.

Keeping episodes costs storage and retains sensitive detail; keeping only abstractions loses qualifiers and evidence. The practical compromise is selective fidelity. Store exact records where future decisions require identifiers, consent, disputed claims or temporal reconstruction. Use derived facts for efficient routine recall, and expand back to episodes when confidence or stakes demand it.

Recency is ranking, not expiry

The recency term in Generative Agents is an exponential decay over time since a memory was last retrieved. It changes rank. It neither marks a fact false nor schedules a record for destruction. Relevance can even favour an obsolete address because the query concerns an address. Importance is likewise no guide to legal retention: an old identity document may remain significant long after its permitted purpose ends.

MemoryBank adds an Ebbinghaus-inspired forgetting mechanism in which elapsed time lowers retention and recall strengthens memory. This models desirable behaviour for a companion, but probabilistic or heuristic forgetting is not a verifiable retention deadline. It cannot guarantee that a particular category disappears after a chosen period, nor that every derived copy disappears with it.

Retrieval should first establish eligibility. Filter by tenant, subject, permissions, purpose and the required temporal view. A current-state query normally excludes facts whose validity has closed. A question such as “where did the user live last year?” deliberately selects a historical interval instead. Only then should semantic, lexical and graph ranking choose useful candidates. Applying recency before these filters optimises attention over the wrong corpus.

Small, stable histories may not justify this machinery; sending an authorised history in full avoids extraction and retrieval omissions. As history grows or changes, measure answer quality and operational cost against that simpler baseline. A memory architecture earns its place by recovering the right evidence with acceptable latency, not by merely reducing stored text.

Correction needs two clocks

Mem0 turns each memory write into a four-way decision. It extracts candidate facts from a new exchange, retrieves similar stored memories, then lets a model choose ADD, UPDATE, DELETE or NOOP. This avoids append-only duplication, but the outcome depends on extraction and candidate recall. If the old contradiction is not among the similar memories, the model cannot resolve it. A DELETE decision also describes a logical write operation, not proof of privacy erasure across the system.

For changing facts, replacement alone destroys useful history. Zep’s bi-temporal model distinguishes when a relationship was valid in the world from when the system created or invalidated its record. When a new relationship contradicts an overlapping old one, it closes the older validity interval while retaining historical relationships. The two clocks matter: a move learnt in August may have happened in July.

That model supports both current and point-in-time questions. It also exposes unresolved cases. Two statements can conflict, describe different scopes, or report different aspects of the same event. Newer information is not automatically more authoritative. Prefer explicit user corrections and trusted system records over inferred preferences; retain uncertainty where evidence does not settle the issue. Deterministic policy should govern which source may close an interval rather than delegating authority to whichever statement arrived last.

Invalidation therefore changes retrieval eligibility, not historical existence. The old fact remains available for an authorised as-of query and for explaining why the agent acted as it did. Privacy law or a retention rule may later require a different outcome.

Govern retention and erasure separately

The GDPR’s Article 5 connects purpose limitation and data minimisation with accuracy and storage limitation. Personal data must be accurate and, where necessary, kept up to date; every reasonable step must be taken to ensure that inaccurate personal data are erased or rectified without delay, having regard to the purposes for which they are processed. Identifiable data must not remain longer than necessary for those purposes, unless Article 5’s conditions for longer archiving, research or statistical storage apply. Article 17 provides grounds for erasure without undue delay, including data no longer necessary for the original purpose, subject to specified exceptions. None of these duties is discharged by lowering a vector score.

Design the lifecycle as explicit states and events. An active fact can become historically invalid while remaining retained. A record can pass its retention deadline and enter a deletion workflow. An erasure request can require action before a routine deadline. Record the purpose, policy version, deadline and legal hold status where applicable; a hold must be an explicit governed exception, not a forgotten flag that disables every deletion.

Deletion must follow provenance in both directions. Remove or appropriately transform the episode, extracted entities and relationships, reflections, community summaries, embeddings and cached prompt material. Cover replicas, exports and evaluation fixtures derived from the same source. Define how backups age out and how a restore prevents deleted identities from re-entering live indexes. An audit event can confirm which stores completed the workflow without retaining the erased content itself.

This propagation is why provenance belongs in the schema from the start. Without a subject and source lineage, a delete API can clear the obvious row while leaving searchable derivatives. Without a separate invalidation flag, teams may destroy history merely to stop stale answers. The data model should make the cheap operation and the correct operation the same one.

Test state transitions, not recall alone

A useful test suite starts with a sequence of events rather than a fixed memory snapshot. Add an address, replace it with a later dated one, and ask both present-tense and historical questions. Check that the current answer uses Bristol, the historical answer uses Leeds, and both cite evidence with the correct validity interval. Repeat with contradictory sources, out-of-order ingestion and a conflict omitted from candidate retrieval.

Test derivation as well as ranking. After a correction, no stale summary or embedding should resurrect the previous current fact. After expiry, scheduled jobs should exclude the record even when its semantic match is strongest. After erasure, inspect every derived store and replay restoration or reindexing to detect reappearance. Include a case where a model chooses NOOP or DELETE incorrectly; lifecycle guarantees cannot rest solely on a model-selected operation.

Monitor pending invalidations, failed deletion propagation, unresolved conflicts and records approaching retention review. Version extractors and policies so an audit can explain which rule produced each transition. A 2026 survey describes research moving from storage through reflection towards reusable experience; its qualitative comparison and recency caveats also show why that direction does not settle production correctness. More abstraction increases the need for lineage and governed transitions.

Agent memory should preserve an evidence-backed assertion whose provenance, validity and permitted lifetime remain explicit from ingestion to removal; retrieval supplies only a task-specific view of that state.

Sources and further reading