AI Agent Memory: A Survey on Solving Catastrophic Forgetting and Context Overflow
This article summarizes a recent survey on AI Agent memory, explaining how it differs from model-internal memory, retrieval-augmented generation (RAG), and context engineering. It breaks down three forms of memory—token-level, parameter-level, and latent-level—and covers self-forgetting and conflict resolution mechanisms, along with practical engineering recommendations for building long-lived agents.
1. Introduction: Why Agents Need a Dedicated Theory of Memory
When building complex agentic applications, developers often run into an awkward reality: short-term context windows, external knowledge retrieval, and long-term interaction state operate as three separate mechanisms, with no unified theoretical framework to tie them together. Recently, several leading research institutions jointly published a survey on AI Agent memory that attempts to answer two problems that have long troubled engineering practice—catastrophic forgetting and context overflow.
The value of this survey lies not only in cataloging existing work, but also in offering a practical layered view: memory is not simply about “storing things,” but a continuously evolving cognitive state that an agent maintains while persisting in an environment over time. For teams building companion bots, autonomous coding agents, or multi-turn task assistants, this framework provides a direct basis for technology selection.
2. Core Definition: What Makes Agent Memory Distinct
2.1 Difference from Model-Internal Memory
Model-internal optimizations—such as reusing key-value caches or extending the context window through new sequence modeling architectures—are essentially close to “GPU memory optimization.” They focus on the efficiency and capacity of a single inference pass. Agent memory spans multiple interaction cycles and carries core cognition such as “who I am,” “what I have experienced,” and “what the user prefers.” It is persistent and dynamically evolving.
2.2 Difference from Retrieval-Augmented Generation
Retrieval is typically a static knowledge add-on, oriented toward one-off queries against a document repository, and the knowledge itself rarely changes due to interaction. Agent memory grows dynamically: every interaction may write in new experience, correct mistaken beliefs, or weaken information that is no longer important, emphasizing interaction history and accumulated experience.
2.3 Difference from Context Engineering
Context engineering is a resource management technique that uses prompt compression and importance filtering to fit critical information into a limited window. Agent memory is cognitive modeling: it decides which information is worth retaining long-term and being invoked again days or months later. The former solves “how to fit it in”; the latter solves “what is worth keeping.”
3. Technical Breakdown of the Three Forms of Memory
3.1 Token-Level Memory
Raw or near-raw interaction fragments are stored in sequence form. This is simple to implement and highly interpretable, making it suitable for short-term tasks and audit scenarios. The challenge is that length grows quickly, so it needs to be paired with summarization and eviction strategies.
class TokenMemory:def __init__(self, max_tokens):self.max_tokens = max_tokensself.buffer = []def add(self, text):self.buffer.append(text)self._evict()def _evict(self):# Illustration: evict by importance or time decaywhile self._count() > self.max_tokens:self.buffer.pop(0)
3.2 Parameter-Level Memory
Experience is consolidated into model weights or a lightweight adapter layer, internalizing capability rather than relying on external concatenation. The advantage is no extra retrieval overhead at inference time; the drawbacks are high update cost, weak interpretability, and the fact that the update process itself can trigger forgetting.
3.3 Latent-Level Memory
Compressed representations are maintained in a continuous vector space, balancing capacity and semantic abstraction. This suits scenarios that need to maintain a consistent persona or preferences across sessions. In engineering practice, it is usually combined with a retrieval mechanism, forming a “compress-store, decode-on-demand” combination.
4. Giving Memory Biological Traits: Self-Forgetting and Conflict Resolution
Self-forgetting is not simply deleting by time, but decaying based on access frequency, recency, and importance, so that noise does not drown out key experience. Conflict resolution requires the system, when new information contradicts old memory, to judge which side is more credible and then overwrite or merge—rather than blindly appending. Only by combining the two can memory bloat and error accumulation be suppressed.
5. Engineering Practice Recommendations
- Layered composition: use token-level for the short term, latent-level for the long term, and parameter-level for stable capabilities.
- Write threshold: not every interaction is worth storing; set significance and confidence thresholds.
- Observability: use general-purpose logging services and monitoring/alerting systems to track memory writes, hits, and evictions.
- Storage and elasticity: raw memory can sit in object storage, hot data can be served by a container platform for inference, and asynchronous writes can be decoupled with a message queue.
- Evaluation loop: build an evaluation set covering long-term consistency, conflict handling, and forgetting correctness.
6. Conclusion
The key to Agent memory is not capacity, but governance. Combining the three forms—token-level, parameter-level, and latent-level—with self-forgetting and conflict resolution mechanisms is what can alleviate both catastrophic forgetting and context overflow. For teams that want to build agents that remain useful over the long term, this framework can serve as a starting point for architecture design, and can be implemented on general cloud infrastructure such as Baidu AI Cloud as an observable, iterable memory subsystem.
