How to Build a Reliable Agent Memory Framework? UC Berkeley's MemFail Stress-Tests 4 Top Memory Systems, Proving Vector Databases Aren't the Only Answer

Over the past six months, nearly every agent framework has been racing to add long-term memory capabilities. The most common approach is to connect a vector database and store everything: historical conversations, user preferences, project experiences, tool call results, and failure cases. It seems that once you patch in this 'memory' module, the agent can evolve from a one-off dialogue tool into a long-term collaborative partner.

But the problem is, long-term memory does not equate to "cramming history into a vector store."

Compression can drop conditions, storage can overwrite coexisting facts, and retrieval can pull back semantically similar but contextually wrong content. The end result is an agent that technically has a memory, but still gives wrong, misapplied, or misused answers, its memory becoming noisier and more chaotic over time.

Image

A recent study from UC Berkeley, titled MemFail: Stress-Testing Failure Modes of LLM Memory Systems, attempts to engineer this problem. It breaks down long-term memory systems into three basic operations—compression, storage, and retrieval—and systematically tests the specific conditions in which they drop conditions, miss facts, misretrieve data, or apply correct memories to incorrect scenarios.

Image

The Three Core Operations and Four Failure Modes of Memory Systems

The researchers first built a formalized framework. In this framework, any external memory system can be deconstructed into three standard operations.

Assuming Q represents the user query, H represents the dialogue history, and M represents the current state of the memory database, the operational flow of the memory system is as follows:

  • Summarization: After an interaction, the raw dialogue history H is compressed into a new representation, H'. The purpose of this step is to extract the information deemed valuable enough to keep.

  • Storage: This step receives the compressed information H' and the existing memory state M, and outputs an updated memory state M'. Specific operations might include overwriting existing entries, merging, appending, or skipping the operation entirely if no update is needed.

  • Retrieval: When faced with a new query Q, the system combines dialogue history H and the current memory state M to extract a set of relevant memories, R. These memories are then inserted into the agent's prompt context alongside Q.

Based on this standardized operational classification, the researchers deduced four failure modes that can afflict any modern memory system:

  • Summarization Failure: The compression operation mistakenly deletes or distorts critical information from the dialogue history H. For example, a user stating "I have a deadly allergy to peanuts" gets compressed to "allergic to peanuts," stripping away the "severity" qualifier crucial for subsequent medical or dietary advice.

  • Storage Failure: The storage mechanism fails to properly integrate the compressed information into the database M. This includes two scenarios: refusing to overwrite outdated facts (e.g., after a user states a preference change, the system retains the old one) and refusing to accept valid coexisting facts (e.g., the system thinks "likes hamburgers" conflicts with the stored "likes pizza" and refuses to log the new fact).

  • Retrieval Failure: The system fails to return memories relevant to the query, or returns snippets that are superficially similar in semantics but useless in the current specific context.

  • Reasoning Failure: The agent makes an incorrect logical judgment despite having retrieved perfectly correct memories. The researchers explicitly note that this is a deficiency of the underlying LLM, not the memory system itself, but they included it in the monitoring scope for analytical rigor.

MemFail's Evaluation Arsenal: An Analysis of the Four Core Tasks

To precisely trigger these failure modes, MEMFAIL meticulously constructed four adversarial tasks across five datasets. Each task acts like a scalpel, specifically cutting into a distinct operational aspect of the memory system.Table 2: Sample sizes, number of scoring questions, and average token statistics for the five MEMFAIL datasets.

Task 1: Conditional Facts

Image
  • Target: Primarily exposes summarization failures. It tests whether the system erroneously discards the preconditions for a fact when compressing and storing information.

  • Construction: Each entry in the dataset contains a core rule: "Entity E will only perform behavior B if condition C is met." This rule is cleverly hidden within a short passage of 5 to 8 sentences, which is also infused with 4 to 7 unconditional distractor facts about the entity.

  • Difficulty Levels:

    • Easy Mode: The complete conditional rule is described in a single sentence. The system only needs the ability to replicate this single sentence verbatim to pass.

    • Hard Mode: The researchers deliberately fragmented the rule into three non-adjacent sentences (a behavior sentence, a condition description sentence, and a linking sentence) and scattered them throughout a longer article. This forces the system to have the logic to reassemble them from dispersed text.

  • Evaluation Method: A specific context X is presented, asking whether entity E will perform behavior B. If the system secretly drops condition C during summarization, it will make an erroneous judgment that ignores context X.

Task 2: Coexisting Facts

Image
  • Target: Simultaneously exposes storage and retrieval failures.

  • Core Challenge: Modern memory systems commonly have an over-alignment tendency. When processing incoming information, they easily misjudge two perfectly compatible preferences (like "likes pizza" and "likes ramen") as logically conflicting. This causes the system to overwrite old facts with new ones instead of storing them side-by-side.

  • Construction: For each row of data, one of 100 pre-set daily preference categories (like food type, hat style) is selected, generating N mutually independent declarative preference statements (N ranging from 2 to 5). Each statement features the user's single favorite item starting with a specific letter.

  • Evaluation Method: A global scenario question is posed that can only be answered perfectly by synthesizing all N preferences.

Task 3: Persona Retrieval

Image
  • Target: Mainly exposes the misattribution phenomenon caused by storage failures. It tests whether the system, when asked about a completely unfamiliar person, incorrectly retrieves stored profiles belonging to other people.

  • Construction: Contains a 10- to 15-sentence biography for entity E, embedded with 4 to 5 highly specific personal eccentricities.

  • Evaluation Method: Three independent scoring queries are set up. Each query has a 50% chance of asking directly about a specific detail of E, and a 50% chance of a deceptive, misleading query. The misleading query asks about a completely non-existent distractor character D from the text. For the misleading query, the system's sole correct reaction is to explicitly state "I give up" or "I lack the information."

Task 4: Long-Hop

Image
Image
  • Target: Focuses on exposing retrieval failures in long-distance causal reasoning.

  • Construction: Each data point encodes a strictly transitive logical chain with K node jumps (K can be 1, 2, or 3). To prevent the LLM from "cheating" with its vast pre-trained world knowledge, all logical nodes are forced to be subjective content (like personal emotions, private items, unique habits).

  • Evaluation Method: During the storage phase, these causal facts are strictly segregated and distributed to the memory system individually. In the questioning phase, only the chain's starting node is given, and the system must deduce the final terminal node. This forcibly cuts off the shortcut of directly reading a single conversation record, compelling multiple cross-database retrievals and assemblies from a sea of fragmented memories.

Experimental Design and System Evaluation Process

To score memory systems with vastly different underlying architectures in a fair and automated manner, the researchers designed a universal automated evaluation pipeline.

This framework only requires the system under test to expose three basic interfaces: storing a dialogue, retrieving memories, and getting all memories. The entire test loop is divided into three phases:

  1. Phase 1: Storage. The required information units (like conditional-fact passages, preference statements) are distributed across separate dialogues for extraction and transmission, forcing the system to store and associate them across sessions.

  2. Phase 2: Query. The test framework creates a query dialogue for each question to be scored, calling the system's retrieve_memories function to get the top k memories. They are then formatted and sent to the test LLM to record its answer.

  3. Phase 3: Grading. This is the core step. The judge LLM (consistently fixed as gpt-5-mini, acting as both tester and judge) receives the query, the true correct answer, all memories stored by query time, and the memories actually retrieved. The judge performs the following checks in order:

    • Storage Check: Does this memory exist in the system's full memory? (Failure is a storage error.)

    • Summarization Check: Given it is stored, are the critical details (like conditional constraints) preserved? (Failure is a summarization error.)

    • Retrieval Check: Given faithful storage, did this entry successfully appear in the top k retrieved set? (Failure is a retrieval error.)

    • Reasoning Check: Given retrieval success, did the test model use it to derive the correct answer? (Failure is a reasoning error inherent to the LLM itself.)

The Four Evaluated Memory Systems

MemFail selected four of the most advanced open-source memory system architectures from academia and industry, each with a fundamentally different internal operational mechanism:Table 1: How the four tested memory systems implement the three operations of summarization, storage, and retrieval.

  • SimpleMem: Saves memory as a flat list of turns, using semantically lossless compression and adaptive embedded top-k retrieval. For more on SimpleMem, you can check out this article:

Image

Making Agents Remember Everything is Foolish: SimpleMem Tops Memory SOTA with 'Structured Semantic Compression'

  • Mem0: Extracts memory into atomic units, with an explicit LLM tool-calling mechanism for ADD, UPDATE, and DELETE operations.

  • A-MEM: Does not use predefined structures but organizes memory as descriptive notes written by an LLM, stored in a vector database.

  • StructMem: Uses a knowledge graph to build hierarchical event structures (typed nodes and edges), returning a subgraph around the queried entity during retrieval.

Unveiling Memory Systems: Key Findings and Data Analysis

Through a large-scale survey of these four leading-edge systems, MEMFAIL revealed a series of system-level characteristics unreachable by traditional aggregate benchmarks.

Finding 1: Increasing Retrieval Quantity is Not a Silver Bullet

One might intuitively think that increasing the number of retrieved memory entries (i.e., enlarging the k value) would certainly boost performance significantly.

But the data gave a counter-intuitive answer: except for a few specific tasks, overall performance improvement was extremely marginal as k increased.Figure 1: Performance of different systems on various tasks as the k value changes, using GPT-4.1-mini as the memory system's internal model.

  • The sole exception was the "Coexisting Facts" task. Since its core failure mode is "retrieval failure," forcibly expanding the lower bound of the retrieval recall naturally stumbles upon more of the relevant parallel preferences.
  • For tasks constrained by "summarization failures" (where key facts are already truncated upon entry), no matter how wide you cast your retrieval net, the lost details can never be recovered. Thus, expanding retrieval scale is pointless.

Finding 2: A More Powerful LLM Does Not Necessarily Mean Better Performance

In typical agent development experience, upgrading the underlying inference model to one with more parameters and greater intelligence often yields an immediate improvement in benchmark scores.

However, in the realm of memory systems, this pattern breaks down. When researchers tried upgrading the systems' internal driving models, they found:Figure 2: Performance changes of StructMem and SimpleMem under different internal models.

  • The introduction of stronger models basically brought no rise in accuracy, and even led to a decline in scores on a majority of tasks.
  • The crux of the problem is that LLMs with extremely strong expressive power tend to generate highly verbose text descriptions when performing memory compression and summarization. These overly wordy memory snippets massively clog and pollute the agent's effective context window, producing severe side effects.
  • This strongly proves that the core bottleneck hindering the current development of memory systems lies in their architectural design limitations, and cannot simply be attributed to insufficient underlying model IQ or context budget.

Finding 3: The Complex Trade-off Between Token Consumption and Performance

Spending more tokens in exchange for accuracy has long been considered a safe scaling strategy. But MEMFAIL reveals that this trade-off in memory storage is highly "task-specific."Figure 3: The relationship between MEMFAIL performance and the average number of tokens per retrieved memory.

  • Positive Gain Zone: In tasks heavily reliant on summarization fidelity (like "Persona Retrieval" and the hard mode of "Conditional Facts"), performance is largely proportional to token consumption. The more tokens a system spends meticulously describing and preserving the source dialogue, the higher its accuracy on nuance control.

  • Negative Gain Zone: In tasks bottlenecked by retrieval capability (like "Coexisting Facts"), spending large amounts of tokens to write lengthy memory entries is a disaster. Long texts substantially dilute the core word vector features, causing severe "pollution" in the underlying semantic vector space, ultimately crashing the hit rate for precise targeted retrieval.

Finding 4: Architectural Choice Dictates Failure Characteristics

The test results clearly show that no single architecture achieves total dominance across all tasks. The underlying architectural choice locks in the system's inherent vulnerabilities from the very beginning.Figure 4: Error type breakdown for the Coexisting Facts task under GPT-4.1-mini.Figure 5: Error type breakdown for the Long-Hop task under GPT-4.1-mini.

  • The LLM Tool-Calling Update School (represented by Mem0):

    • Performs state updates by having the LLM trigger tool calls.
    • When processing short, explicit single-sentence information, its storage is extremely precise.
    • But when dealing with lengthy, winding personal history summaries, the LLM frequently suffers from "call fatigue," failing to automatically generate enough API calls to capture all details, leading to a high storage failure rate exploding in the "Persona Retrieval" task.
  • The Flat Vector Description School (represented by A-MEM):

    • Abandons a preset data schema and relies purely on converting experiences into large text blocks of notes and stuffing them directly into a vector database.
    • Tests proved that this practice consumes a staggering amount of tokens to little effect. While it reduces the risk of lost information from summarization, when faced with relational retrieval for isolated entities, traditional RAG similarity matching completely fails to capture causal chains, resulting in exceedingly low retrieval efficiency.
  • The Graph Structure School (represented by StructMem):

    • Maintains relationship networks by building nodes and edges.
    • Shines in tasks requiring logical transitivity and causal decomposition (Long-Hop, Conditional Facts).
    • But experiences a complete collapse in routine, general information clustering and extraction tasks (like Coexisting Facts). This exposes the graph architecture's tendency to become overly obsessed with structural decomposition, thereby destroying the coherent representation of long, complete semantic concepts.

Design Directions for Future Memory Systems

Based on the massive repository of failure samples forged by MEMFAIL, the researchers have pointed out two highly promising research directions for developing the next generation of memory systems without blind spots.

Mixture-of-Memories Architectures

Current industry R&D approaches are mostly confined to doggedly sticking to a single underlying storage logic (be it all vectors, all graph databases, or all hierarchical trees).

Since different architectures possess absolute advantages on their corresponding tasks, future memory systems can definitely stride into a "hybrid routing" era.

  • By introducing a front-facing classifier, the system can intelligently identify the characteristics of incoming information.
  • For experiential data with strong causal logic and time-series features, route it to a graph structure backend (borrowing StructMem's strengths) for modeling.
  • For loose preference descriptions and massive persona fact libraries, route them to a flat vector storage backend (borrowing A-MEM's strengths) for archiving.

Task-Based Token Scaling

Current systems often use fixed-length prompt templates for indiscriminate output when generating memory entries, leading to a serious misallocation of resources.

  • Future memory frameworks should possess dynamic awareness, adaptively adjusting the token budget used for generating memories based on the information entropy of incoming data and the task type.
  • For detail-oriented logical rules requiring high fidelity, the system should allocate a larger generation quota to strive for accuracy; for scattered preferences requiring high-frequency retrieval and parallel categorization, the system should perform extreme compression to avoid redundancy pollution in the embedding space.
  • The core philosophy is: blindly piling on tokens is by no means the only path to a universal memory.

Conclusion

The launch of "MemFail" marks an advancement in testing methods for the long-term memory of large language models, shifting from "black-box scoring" to "white-box diagnosis." With its highly targeted task design, it ruthlessly lays bare the architectural shortcomings underlying the so-called "intelligent memory systems" of our current era.

Through detailed data, it confirms that simply relying on improving the LLM's intelligence or blindly amplifying the recall threshold cannot genuinely repair the deep failure modes caused by the system's foundational architecture. By fully open-sourcing its evaluation standards and code suite, MEMFAIL is providing the crucial verification benchmark for building the next generation of truly robust, flexible, and comprehensive long-term memory infrastructure for large language models.

The future is already here. Let's walk together on this destined path!

<End of Article>

  1. Please contact the author for reprinting. Unauthorized scraping and reprinting will face legal action.
🎉Let's create more beautiful things together!🎉
If you found this article helpful
Thank you for giving me a 【Like】 and 【Watching】
<Your likes and watches are seen only by me>
👉WeChat: xiumaoprompt
Please state your purpose when adding!
Related Articles

分享網址
AINews·AI 新聞聚合平台
© 2026 AINews. All rights reserved.