How AI Agent Memory Works: From Fragmented Solutions to a Unified Architecture
Memory has become a central challenge for AI agents as large language models evolve from one-shot question answering toward long-term interaction with users and environments. This article breaks down a recent comprehensive survey on AI agent memory produced by researchers from several leading universities, explaining how agent memory differs from LLM memory, RAG, and context engineering, the three main paradigms for building memory systems, and the mechanisms that give memory human-like forgetting and conflict resolution capabilities. It also offers practical engineering guidelines for developers building companion bots, autonomous coding agents, or any application requiring sustained interaction.
I. Why Agent Memory Is Now a Core Topic
The capability boundary of large language models is shifting from “single-turn Q&A” toward “long-term coexistence.” Whether it is a companion chatbot or an autonomous coding agent, they all face the same fundamental problem: model weights are static, while the environment and the user keep changing. A user preference learned today may be outdated tomorrow; an experience summarized last week may need to be overturned next month.
Current solutions in the industry are notably fragmented. For the short term, some teams rely on optimizations at the KV cache level; for the medium term, some depend on retrieval-augmented generation (RAG) as an external knowledge layer; and for the long term, some borrow the paging concepts of operating systems to design hierarchical memory architectures. Each approach solves part of the problem, yet there is no unified theoretical framework to answer three key questions: what to remember, how to store it, and when to forget.
A recent comprehensive survey on AI agent memory, jointly published by researchers from the National University of Singapore, Renmin University of China, Fudan University, and other leading institutions, represents a systematic effort to organize this field. It not only reviews existing work but also attempts to provide a systematic solution for addressing “catastrophic forgetting” and “context overflow.”
II. Key Definitions: The Distinct Territory of Agent Memory
Before diving into technical details, three frequently confused concept boundaries must be clarified. The survey’s definitions here are rigorous and worth examining one by one.
1. Agent Memory vs. LLM Memory
LLM memory is essentially a technical optimization for inference efficiency. It focuses on how to reuse key-value caches more efficiently within a single forward pass of a Transformer, or how to extend the context length a single inference can handle through linear attention architectures (such as state space models and linear RNN-like structures). Using a computer architecture analogy, this is closer to “VRAM management”—it serves the efficiency and capacity of a single call.
Agent memory is entirely different: it is a persistent, dynamically evolving cognitive state that an agent maintains in order to exist in an environment over the long term. It carries not just data, but three categories of core cognition—“who I am” (self identity and role configuration), “what I have experienced” (interaction history and event sequences), and “who the user is and what they prefer” (a world model of the interaction counterpart).
In one sentence: LLM memory optimizes a single inference; agent memory models a life story.
2. Agent Memory vs. RAG
RAG is a static knowledge attachment. Consider an enterprise document Q&A scenario: when the model receives a question, it retrieves relevant snippets from a vector database or knowledge graph, concatenates them into the prompt, and generates an answer. The knowledge base itself rarely changes with interactions—it addresses the problem of “what I know.”
Agent memory grows dynamically. Every interaction is a write opportunity: new experiences are accumulated, mistaken beliefs are corrected, and outdated information is forgotten. The division of labor can be understood this way:
- RAG handles “external world knowledge”—relatively stable and statically indexable;
- Agent memory handles “interaction experience knowledge”—continuously changing and requiring evolutionary management.
That said, the two are not mutually exclusive. In modern agent systems, RAG often serves as one implementation mechanism for reading and writing agent memory, but RAG by itself is not a memory system.
3. Agent Memory vs. Context Engineering
Context engineering is a resource management technique: because the model’s window is limited, developers use prompt compression, importance filtering, information layering, and other techniques to fit “the most valuable information right now” into the limited window. It answers the question “how to fit it in.”
Agent memory is cognitive modeling: it decides which information is worth consolidating into long-term memory and ensures that this information can still be accurately recalled days, months, or even years later. It answers the question “what to fit in and what to keep.”
The relationship between the two can be described with an analogy: context engineering is the CPU scheduler, while agent memory is the file system. No matter how good the scheduler is, without correct data on disk, nothing works.
III. Three Approaches to Building Agent Memory
A core contribution of the survey is consolidating scattered engineering practices into three memory construction paradigms. Understanding the differences among these three routes is the first step in technology selection.
1. Token-Level Memory: Explicit Textual Form
Memory is explicitly stored as natural language or structured text. Typical practices include:
- Conversation history summarization: periodically compressing long conversations into key-point notes;
- Structured notes: storing information as fact triples or user profile fields for precise retrieval and updating;
- Episodic memory paging: slicing complete interaction histories into segments and loading them on demand.
The advantages are interpretability, editability, and natural compatibility with existing LLMs; the drawbacks are that storage cost grows linearly with interaction volume and retrieval quality depends heavily on the embedding model and ranking strategy.
2. Parametric-Level Memory: Implicit Weight Form
Through continual learning or fine-tuning, important information is consolidated directly into model parameters. The advantage of this route is that no extra retrieval is needed at call time and inference overhead is low; but the risks are significant—incremental training can easily trigger catastrophic forgetting, where new knowledge overwrites old capabilities, and training is costly and difficult to roll back. It is suitable for slowly changing “world knowledge,” not for frequently updated user-level states.
3. Latent-Level Memory: Compressed Vector Form
Experiences are compressed into continuous latent representations (such as memory vector pools or learnable soft prompts) that are injected as additional context during inference. This approach tries to strike a balance between representational density and retrieval efficiency: more compact than token-level memory, more flexible than parametric-level memory. The cost is reduced interpretability, making debugging and auditing harder.
A selection sketch (pseudocode logic) for the three forms:
def choose_memory_form(info):if info.high_update_freq and info.user_specific:return "token-level" # Frequent add/update/delete needed; explicit text is most controllableif info.stable and info.general_purpose:return "parametric-level" # World knowledge; consolidate at low frequencyif info.densed_and_recurrent:return "latent-level" # High-frequency recurring patterns; store in compressed form
IV. Giving Memory an Organism-Like Ability to Evolve
Another highlight of the survey is its emphasis on two meta-capabilities that memory systems must possess—“self-forgetting” and “conflict resolution.” These are also what distinguish agent memory from an ordinary database.
Self-forgetting: This is not simple capacity-based eviction, but proactive management based on information value. Each memory can be scored by combining time decay, access frequency, and relevance to the current task, and low-value memories are periodically cleaned out. This resembles the forgetting curve mechanism of the human brain: memories that are never recalled gradually fade until they disappear.
Conflict resolution: When new information contradicts existing memories, the system needs an arbitration logic. Typical strategies include timestamp priority (newer information overrides older information), weighting by source trustworthiness, and, when no verdict is possible, retaining both versions and disambiguating during downstream generation. For example, if a user said last month “I drink Americano” and this month says “I’ve switched to latte lately,” the memory system should not break down—it should update the preference while preserving the timeline.
V. Engineering Best Practices
Combining the survey’s framework with real-world deployment experience, the following principles can serve as a reference when building an agent memory system:
- Layered design: short-term memory (the current conversation window) + working memory (recently compressed summaries) + long-term memory (persistent storage), with the layers connected through write and distillation pipelines;
- Explicit before implicit: start with token-level approaches to guarantee controllability and auditability, and only consider vectorized compression once patterns stabilize;
- Model memory operations explicitly: design “write, retrieve, update, forget” as tools that the agent can invoke, rather than hiding them inside the system as a black box;
- Evaluation loop: establish quantitative metrics such as memory hit rate, conflict rate, and staleness rate to continuously monitor memory quality;
- Leverage cloud infrastructure: general-purpose cloud services such as vector databases, object storage, and message queues can provide a reliable storage and asynchronous processing foundation for memory systems. For enterprise deployment, building on these common components helps avoid reinventing the wheel.
VI. Conclusion
The real value of this survey lies in bringing previously siloed engineering practices—KV cache optimization, RAG, and long-term memory architectures—into a single theoretical coordinate system. For developers building companion bots, autonomous coding agents, or any intelligent application requiring long-term interaction, it offers more than conceptual clarification: it provides a thinking framework that can directly guide architectural decisions—first clarify the boundaries and forms of memory, then design the evolution mechanisms, and finally ensure reliable deployment through engineering. Memory is evolving from an auxiliary feature of agents into their core competitive advantage.
