Back to list

Storage is infinite, attention is not

Jim Lin
AGITech

When I wrote about Hermes Agent's memory architecture, I focused on the design philosophy of a single product. After a month of heavy use, more and more questions came up. Is this layered design a choice unique to Hermes, or is it an industry consensus? If I switched to a different agent framework, how should memory be designed? Is there anything you can't avoid no matter how you build it?

With those questions in mind, I spent some time taking apart how six mainstream agent memory systems are implemented. The conclusion was clearer than I expected: everyone is converging in the same direction. Only the paths differ.

A hundred flowers blooming

First, let's lay out the landscape and look at how a few of the main open-source memory frameworks are built.

TencentDB Agent Memory, recently open-sourced by Tencent, takes the "semantic pyramid" route. It has four layers: L0 raw conversations, L1 atomic facts, L2 scene aggregates, L3 user profile. Every layer is kept. Each upper layer is a compression of the one below, but you can always drill back down to the raw record. Combined with Mermaid-based symbolic short-term compression, it saved 33% of tokens on sequential SWE-bench tasks and 61% in WideSearch scenarios.

Mem0 is currently the most-starred memory framework (55k+), and it takes the "flat fact pool" route. No layers. Every memory is an atomic fact, retrieved through a three-way fusion of BM25, vectors, and entity linking. Its new algorithm from April 2026 pushed the LoCoMo benchmark to 92.5, matching the accuracy of full-context approaches (25k+ tokens) at a retrieval cost under 7k tokens.

Letta (formerly MemGPT) takes the "operating system virtual memory" route, borrowing directly from OS design. Main Context is RAM (currently active data), Recall Storage is disk (searchable message history), and Archival Storage is cold storage (vector-indexed long-term knowledge). The agent decides through function calls when to page in and when to archive out.

Hermes Agent takes the "bounded curation" route. Two Markdown files (under 4,000 characters combined) serve as core memory, SQLite FTS5 handles session search, and 8 optional external memory providers extend it. The capacity is small, but the agent itself manages what is worth remembering and what should be evicted.

Stanford's Generative Agents (2023) is the pioneering academic work. A Memory Stream records every observation, periodically clusters them into higher-level Reflections, and at retrieval time scores memories by weighting three signals: time decay × relevance × importance. With this mechanism, 25 simulated characters spontaneously organized a Valentine's Day party.

Voyager (Microsoft, 2023) focuses on procedural memory. It doesn't store conversations or facts, only verified executable code. Each new skill it learns goes into a Skill Library, and the next time a similar task comes up, it calls that skill directly. It advanced through the tech tree 15.3 times faster than the baseline.

Where they differ

The differences among the six come down to three design decisions.

The first split: layered or flat.

TencentDB and Letta insist on layers. They believe information at different levels of abstraction should live on different "floors." Mem0 insists on flat. It believes all facts are equal, and that a good retrieval algorithm matters more than a good storage structure.

Both sides have hard data. TencentDB's layering raised accuracy on the PersonaMem (personalized memory) benchmark from 48% to 76%, because a profile layer is naturally suited to questions like "what kind of person is this user." Mem0's flat pool hit 92.5 on the LoCoMo (factual QA) benchmark, because atomic facts plus precise retrieval are naturally suited to questions like "what did we say last time."

The conclusion is clear: nobody is right or wrong, the scenarios are different. For fact retrieval, a flat pool works better. For personalized understanding, a layered pyramid works better.

The second split: agent-managed or rule-driven.

Letta lets the LLM decide when to store, retrieve, and delete (by exposing a memory API as tool calls). Hermes uses a fixed character cap plus agent-driven curation. TencentDB uses scheduled pipelines (extraction triggers every N turns, a profile update triggers every M new memories).

An early 2026 paper (Agentic Memory) used RL to train a memory management policy, and it beat all of the above across five long-horizon benchmarks. The trained policy does some counterintuitive things: for example, it summarizes proactively before the context is full, and it discards new records that are semantically similar to existing memories but add no information.

The cost is very high training expense and poor interpretability. But the direction is clear: memory management will eventually be learned, not written as rules.

The third split: keep the raw records or not.

TencentDB's core claim is "lossless and traceable": compression is an index layer, and the raw data is always there. Mem0 is ADD-only and doesn't delete raw facts either. But Hermes's core memory is curated: old entries get merged or deleted, and raw records are kept only in the Session DB.

Behind this split are different attitudes toward "what to do when memory goes wrong." Keeping raw records means you can always audit and correct, but storage and retrieval cost more. Not keeping them is leaner, but once compression goes wrong, there is no recovery.

My call for production: you must keep them. Summarization drift (key information lost after rounds of compression) is not a theoretical risk, it actually happens. An instruction like "never call the production database directly" will very likely disappear after three rounds of summarization.

What they share

That's the differences. Now the common ground. These are the conclusions every team reached eventually, whichever path they took.

Consensus one: long context is not memory.

By 2026 this is no longer controversial. The MemoryArena benchmark shows that models with 200k-token context score near perfect on passive recall tasks, but drop to 40-60% on multi-session tasks that require actively managing memory. Stuffing everything into context isn't memory, just as spreading every book across your desk isn't "knowing."

Consensus two: you need at least two layers (working memory + long-term storage).

No agent system that has run in production is single-layered. Even the simplest implementation (Hermes's two Markdown files) distinguishes between "core knowledge that's always in context" and "past sessions retrieved on demand."

Consensus three: hybrid retrieval beats single-method retrieval.

Fusing BM25 keywords, vector semantics, and other signals (entities, time, importance) is standard in 2026. Mem0's multi-signal retrieval, TencentDB's hybrid recall, and Generative Agents' three-signal weighting all arrive at the same place by different roads. The era of pure vector retrieval is over.

Consensus four: memory needs active management.

Append-only works in the short term, but any agent that runs more than a few dozen sessions will see retrieval precision degrade over time. Compression, deduplication, and forgetting are all necessary. There's just no standard answer yet for how to manage it.

Consensus five: auditability is not optional.

When memory affects an agent's decisions (and it always will), you have to be able to trace "why did the agent remember this" and "which conversation did this belief come from." Black-box memory is acceptable in a demo. In production it isn't.

What doesn't change

Abstracted to the bottom, every design choice in agent memory follows from one constraint:

Storage is infinite. Attention is finite.

You can store every conversation, every fact, every skill (storage is cheap). But the amount of information an agent can "see" each time it makes a decision is fixed (the context window is finite). So you need a mechanism that decides which information is worth "seeing" right now.

This constraint is exactly what drives the computer memory hierarchy: Register → L1 Cache → L2 Cache → RAM → SSD → HDD → Cloud Storage. The closer storage is to the CPU, the faster, smaller, and more expensive it gets. The memory hierarchy isn't a design pattern some engineer made up on a whim. It's a direct consequence of physics.

Layered agent memory isn't some team's "design choice" either. It's the inevitable result of the same constraint:

  • The closer a memory is to the context window (the "CPU"), the higher its density, the smaller its capacity, and the slower it updates
  • The farther a memory is from the context window, the larger its capacity, the lower its density, and the more it needs retrieval to be accessed

That's why everyone ends up converging on similar structures. They aren't copying each other. The constraint is the same, and the solution space is only so big.

Starting from this first principle, you can derive a few design rules that won't change:

1. Separate working memory from long-term memory

Because the context window will never truly be infinite. Even if it grows to 1M tokens, attention dilution (the "lost in the middle" problem) will make a stuffed context ineffective. So current memory and long-term memory have to be kept apart.

2. Have a write policy that decides what to store

Not all information is equally important. If you store everything, retrieval precision will inevitably degrade, and you'll also pollute the memory.

3. Have a read policy that decides what to load

Relevant information should be loaded into working memory to extend the context of the current conversation. This is a retrieval problem, but not just similarity retrieval. It also covers recency, importance, and relevance to the current task.

4. Distill episodic memory into semantic memory

There has to be some form of "distillation" that turns episodic memory into semantic memory, because raw records are too verbose to fit directly into limited working memory. From "yesterday the user corrected the date format, last week the user corrected it again, and this week too," you need to distill "the user prefers the DD/MM/YYYY format."

5. There must be some form of "forgetting"

Because the world changes and users change, and stale memories are more dangerous than no memory. New information keeps flowing in. To keep information current, you have to forget past mistakes and outdated information.

These five rules don't depend on any specific implementation technology (vector databases, knowledge graphs, SQL, and Markdown files all work), and they don't depend on the underlying model (GPT, Claude, DeepSeek, same thing). They follow directly from the constraint that attention is finite.

Why it looks so much like the human brain

This is no coincidence.

Over the past fifty years, cognitive science has been studying the same problem: how does the human brain manage decades of life experience with limited working memory capacity (Miller's 7±2, which Cowan revised to 4 chunks)?

The answer is layering. The Atkinson-Shiffrin model (1968) proposed a three-stage structure: sensory register → short-term memory → long-term memory. Tulving (1972) split long-term memory into episodic and semantic memory. Squire (2004) added procedural memory. Baddeley (2000) expanded short-term memory into a working memory system with a central executive and buffers.

These categories aren't subjective inventions by psychologists. They were validated through large numbers of brain injury cases and fMRI studies. Damage to the hippocampus makes it impossible to form new episodic memories while leaving procedural memory intact (patient H.M. could learn new motor skills but didn't remember the learning), which proves these memory types are separate at the neural level.

The similarity between agent memory layers and human memory layers comes from facing the same constraint: how to organize unlimited experience with limited "attention bandwidth." For the brain, the constraint is working memory capacity. For an agent, it's the token limit of the context window. Same constraint, similar optimal solution.

There's a more specific correspondence worth noting. Human memory consolidation happens during sleep: during the day the hippocampus holds episodic memories temporarily, and during slow-wave sleep at night they are transferred to the neocortex to form semantic memories. The process is selective (not every memory gets consolidated), gradual (it takes multiple replays), and transformative (memories get abstracted).

TencentDB's L0→L3 pipeline is almost an engineering simulation of this process: triggered every five turns by default, selective extraction, gradual abstraction, and raw records kept "for reference." Hermes's frozen snapshot pattern (keeping cognition stable while online and finishing memory updates in the gaps between sessions) maps onto the same logic.

This convergence tells you something: good agent memory design doesn't need to "imitate the brain." It just needs to face the constraint honestly, and it will naturally arrive at a similar architecture.

If I were designing from scratch

Based on all this, if I had to design a memory system for an agent from scratch today, I'd do it in three steps.

Step one: minimum viable memory (covers 80% of cases). Two layers. The upper layer is core knowledge injected into the system prompt (user profile + environment facts + key preferences), kept under 1,000 tokens. The lower layer is an atomic fact store with hybrid BM25 + vector retrieval, extracting new facts at the end of each conversation. That's the essence of Mem0. If it runs, run it first. In fact, in our internal projects, building a memory layer ourselves this way has worked really well.

Step two: add distillation and compression (to fix long-term degradation). Once the fact pool grows past a few hundred entries, the precision of pure retrieval starts to degrade. That's when you bring in TencentDB-style layered distillation: periodically aggregate related atomic facts into scenes, then extract a profile from the scenes. The profile goes into the system prompt, the facts below are retrieved on demand. The key is keeping the whole chain traceable.

Step three: add procedural memory (to stop repeating work). Once the agent starts doing similar tasks over and over, bring in a Skill system. Store verified workflows as reusable templates and load them on demand. This step doesn't affect the architecture of factual memory. It's a separate track.

Each step is a natural extension of the previous one. You never have to tear it down and start over.

My take

After this round of research, a few judgments got clearer.

The agent memory field is converging fast. In 2023 it was still a hundred flowers blooming (Memory Stream, Virtual Memory, and Skill Library each going their own way). By 2026 everyone has reached consensus on the core architecture. The differences show up more and more in engineering details rather than design philosophy.

"Attention is finite" is the one root constraint. Every layering, compression, retrieval, and forgetting strategy follows from it. Once you understand that, you can look at any new memory approach and quickly tell what problem it solves and which layer it optimizes.

The most underrated direction right now is the "management loop." Academia and industry have both poured a lot of effort into writing and reading (better embeddings, better retrieval algorithms), but management decisions like "when to write, when to forget, how to resolve conflicts" are still very primitive. Agentic Memory's direction of training a management policy with RL is right, but it's far from mature.

The hardest problem right now is "selective forgetting." MemoryAgentBench is the only benchmark that explicitly tests forgetting, and the result: no system passed. The brain's forgetting mechanism is so refined we barely notice it working (you won't remember what you had for lunch on some Wednesday last year, but you remember you're allergic to peanuts). Agents have a long way to go to reach that level.

For my own agent product design, the biggest lesson is: don't chase a perfect five-layer architecture from day one. Start with a Mem0-style two-layer MVP, get the core loop working (extract → store → retrieve → inject), then evolve step by step based on the problems you actually hit (token explosion, add compression; not personal enough, add distillation; repeated work, add skills). Every layer you add should be driven by a clear problem, not by architectural elegance.

References

  1. Tencent/TencentDB-Agent-Memory
  2. Mem0: The Memory Layer for AI
  3. Letta (formerly MemGPT)
  4. NousResearch/hermes-agent
  5. Park et al., "Generative Agents: Interactive Simulacra of Human Behavior" (2023): arxiv.org/abs/2304.03442
  6. Packer et al., "MemGPT: Towards LLMs as Operating Systems" (2023): arxiv.org/abs/2310.08560
  7. Du, "Memory for Autonomous LLM Agents: Mechanisms, Evaluation, and Emerging Frontiers" (2026): arxiv.org/abs/2603.07670
  8. Yu et al., "Agentic Memory: Learning Unified Long-Term and Short-Term Memory Management" (2026)
  9. Mem0 Research: Token-Efficient Memory Algorithm
  10. Atkinson & Shiffrin, "Human Memory: A Proposed System and Its Control Processes" (1968)
  11. Tulving, "Episodic and Semantic Memory" (1972)
  12. Baddeley, "The Episodic Buffer: A New Component of Working Memory?" (2000)
  13. Ebbinghaus, "Über das Gedächtnis" (1885)