17 min read

2026 AI Agent Memory Wars: Three Architectures, Three Philosophies

Table of Contents

Your AI Agent can’t remember what you said yesterday.

This isn’t a bug—it’s a structural deficiency. LLMs are inherently stateless. The context window is their entire memory, and closing the window wipes the slate clean.

In 2025, the answer was RAG: stuff conversation history into a Vector DB, retrieve when needed. But RAG has a fundamental problem—how do you know what to retrieve?

In 2026, three radically different answers emerged at once.


Why “Memory” Suddenly Became the Battleground

If you’ve used an AI coding agent, you’ve lived this scenario:

Monday, you tell the AI: “Our project uses Kotlin, follows Clean Architecture, and Dispatchers must be injected via DI.” AI performs perfectly.

Tuesday, you start a new session. It writes Dispatchers.IO again. You explain again.

Wednesday, same thing.

Your AI is that coworker who has to re-introduce themselves every morning.

In 2025, this was treated as a “tolerable inconvenience.” By 2026, as Agents took on more complex tasks—cross-session debugging, long-term project maintenance, multi-user collaboration—“can’t remember” went from annoying to fatal.

Three teams came up with three very different answers:

SchoolRepresentativesCore PhilosophyOne-Liner
Graph-basedMem0, ZepStructure memory as a knowledge graph”Remember the relationships between facts”
OS-inspiredLetta (formerly MemGPT)LLM as operating system, memory as virtual memory”Let the Agent manage its own memory”
ObservationalMastraBackground Agent compresses conversations into observation notes”Compress everything, stuff it into context”

This article breaks down each school’s design philosophy, technical architecture, and trade-offs—not just “what it is,” but more importantly, “why it’s designed this way” and “when to use which.”


School 1: Graph-based — Memory as Knowledge Graph

Design Philosophy

The core belief of Graph-based memory: memory isn’t a pile of isolated facts—it’s a structured knowledge network.

“User likes Kotlin” is a fact. But “user likes Kotlin, uses Clean Architecture in a project, and requires Dispatchers to be DI-injected”—the relationships between these three facts are the truly valuable memory.

Vector DBs can store facts, but not relationships. Searching for “Kotlin” might find the first one but won’t automatically surface the other two. Graph DBs can—because they store entities as nodes, relations as edges, and a single traversal pulls out the entire context.

Representative 1: Mem0 — Two-Stage Extraction Pipeline

Mem0 is the pioneer of this school, raising $24M Series A in 2025 and becoming AWS Agent SDK’s exclusive memory provider.

Architecture:

Conversation → [LLM #1: Extraction] → Extract entities + relations
                                              ↓
                                      [LLM #2: Update] → Decide add/update/delete
                                              ↓
                                      Vector DB + Graph DB (Neo4j)

After each conversation, Mem0 processes memory with two LLM calls: the first extracts information, the second decides how to update. The benefit of this pipeline is high structural fidelity—you end up with a clean knowledge graph, not a blob of compressed text.

Mem0ᵍ (Graph Memory) is its advanced version, supporting Neo4j, Memgraph, and other graph backends. It stores entities as nodes, relations as edges, paired with vector embeddings for hybrid search.

Data (from arXiv:2504.19413):

  • 26% accuracy improvement over OpenAI Memory (LOCOMO benchmark)
  • P95 latency reduced by 91%
  • Token cost savings of 90%

Representative 2: Zep — Temporal Knowledge Graph

Zep uses a more sophisticated design: bi-temporal knowledge graph.

Ordinary knowledge graphs are static—“user likes Python” is an eternal fact. But real-world facts change. Three months ago the user liked Python, last month they switched to Rust, this week they’re considering Zig.

Zep’s Graphiti engine records two timelines for each edge:

TimelineWhat It RecordsUse Case
Event Time (T)When the fact was true in the real world”User liked Python from 2025-06 to 2025-12”
Ingestion Time (T’)When the fact was ingested by the systemAudit trail, conflict resolution

When new facts contradict old ones (“user now likes Rust”), Zep doesn’t delete the old edge—it invalidates it by setting a t_invalid marker. This means you can do point-in-time queries: “What were the user’s preferences three months ago?”

The retrieval design is also worth examining:

Query → [Cosine semantic search]  ─┐
      → [BM25 keyword search]      ├→ Hybrid ranking → LLM Reranking → Context
      → [BFS graph traversal]     ─┘

According to Zep’s official description, Graphiti supports hybrid queries combining “time, semantic, full-text, and graph algorithm.” Three search strategies run in parallel, with LLM reranking assembling the final context.

Data (from arXiv:2501.13956):

  • LongMemEval accuracy improved by 18.5% (GPT-4o)
  • Median latency 2.58s vs. full-text baseline 28.9s (90% reduction)
  • Context uses only 1.4% of baseline tokens (1.6k vs. 115k)

Graph-based Trade-offs

Strengths:

  • Highest structural fidelity—knowledge has explicit entity/relation structure
  • Supports complex queries (multi-hop reasoning, temporal reasoning)
  • Suitable for multi-user shared memory

Costs:

  • Ingestion requires LLM calls—every conversation runs an extraction pipeline, adding cost and latency
  • Graph maintenance is complex—entity deduplication, edge invalidation all need careful design
  • Risk of over-structuring—not all memory fits neatly into entity-relation format

School 2: OS-inspired — Let the Agent Manage Its Own Memory

Design Philosophy

Letta’s (formerly MemGPT) core belief: don’t manage memory for the Agent—let it manage its own.

This idea comes directly from operating system design. Your OS doesn’t need you to manually decide what goes in RAM vs. disk—it has virtual memory to handle that automatically. Letta applies the same thinking to LLMs:

OS ConceptLetta Equivalent
RAM (main memory)Core Memory (always in context)
Hard diskArchival Memory (semantic search)
Virtual Memory PagingAgent autonomously decides when to access
Page FaultAgent discovers needed info isn’t in context

Three-Tier Memory Hierarchy

Tier 1: Core Memory (always in context)

Core memory is a set of structured text blocks embedded directly in the system prompt, visible to the Agent on every inference. It has two default blocks:

  • persona: Agent’s identity, behavior patterns
  • human: User’s preferences, history, context

The key design: the Agent can modify these blocks itself. Letta provides core_memory_append and core_memory_replace tools—the Agent decides when to update and what to update.

# Agent autonomously decides to remember this preference
core_memory_replace(
    block="human",
    old="Uses Python for most projects",
    new="Recently switched from Python to Rust for systems work"
)

Tier 2: Archival Memory (semantic search)

Long-term knowledge that won’t fit in core memory—past conversation summaries, learned patterns, project history. The Agent proactively searches via archival_memory_search.

Tier 3: Recall Memory (conversation history)

Complete event log including all messages, tool calls, and reasoning traces. When capacity is exceeded, automatic recursive summarization kicks in.

Letta Code: A Memory-Driven Coding Agent

In February 2026, Letta launched Letta Code—a coding agent built on its memory architecture that achieved #1 among model-agnostic open-source frameworks on Terminal-Bench.

Its secret weapon is the Skill Library: the Agent stores learned patterns as .md files (API migration steps, dashboard creation workflows, common bug fixes) and automatically invokes them when facing similar problems.

Even more notable are Context Repositories—using Git for memory version control. The Agent’s memory can be committed, branched, and even rolled back.

OS-inspired Trade-offs

Strengths:

  • Highest autonomy—Agent controls its own memory lifecycle
  • Good explainability—you can directly read the Agent’s core memory to understand “what it remembers”
  • Continuous learning—Agent accumulates experience over time, improving with use

Costs:

  • High fixed context window cost—system prompt + tool definitions + core memory eat ~2,000 tokens before the conversation even starts
  • Self-editing is risky—Agent might accidentally delete important memories or write incorrect information
  • Page faults are expensive—just like a real OS, when the Agent discovers needed memory isn’t in Core Memory, it must search Archival Memory (one RAG call + one LLM inference). The latency of this “page fault” can be fatal in real-time response scenarios
  • An interesting self-contradiction—Letta’s own research found that on the LoCoMo benchmark, an Agent using basic filesystem operations (74.0%) beat an Agent using Mem0’s graph memory (68.5%)

That last point is worth sitting with. Letta’s team concluded: “Current agents are very proficient at using tools, particularly those commonly encountered in training data (such as filesystem operations).” This hints at a possibility—maybe the best memory system doesn’t need a special architecture, just the tools the Agent is most familiar with.


School 3: Observational — Compress Everything, Stuff It into Context

Design Philosophy

Mastra’s Observational Memory is the most radical of the three: no retrieval, no external databases, compress all memory into plain text and stuff it into the context window.

This sounds absurd. Context windows are finite—how can you fit everything in?

The answer: compression is more effective than you’d think.

Dual-Agent Compression Architecture

Mastra divides the context window into two zones:

Context Window
├─ Observations (compressed memory)         ← Stable, cacheable
│    Structured text notes with dates + priority
│    Exceeds 40k tokens → Reflector cleans up
│
├─ Raw Messages (original conversation)     ← Append-only
│    Uncompressed recent conversation
│    Exceeds 30k tokens → Observer compresses

Two background Agents handle memory management:

Observer: When raw conversation exceeds 30k tokens, the Observer compresses it into structured observation notes with date and priority markers:

🔴 2026-03-02 User's Android project uses Clean Architecture
  - Dispatchers must be DI-injected (lint rule enforced)
  - Don't use Dispatchers.IO, use @Dispatcher annotation instead

🟡 2026-03-01 User is writing an AI Agent Memory article series
  - Target audience: L5+ engineers
  - Requires technical depth + real-world trade-offs

Reflector: When observation notes exceed 40k tokens, the Reflector performs “garbage collection”—merging duplicates, removing outdated information, retaining high-priority memories.

Why This Beats RAG

Traditional RAG:

Query → Embedding → Vector Search → Reranking → Context Assembly → LLM

Every step has information loss. Imprecise embeddings, incomplete search results, reranking might miss critical context.

Observational Memory:

Messages → Observer compression → Directly in Context → LLM

No retrieval gap. All relevant memory is always in context—the “what to search for” problem doesn’t exist.

And it’s cheaper. Because the Observation block is stable (only changes during compression), it benefits perfectly from prompt caching. According to Mastra, most model providers offer 4-10x token cost discounts for cache hits.

Compression Efficiency

Conversation TypeCompression RatioWhy
Pure text3-6xHuman language has massive redundancy
With tool calls5-40xJSON output is extremely redundant (10 API calls compressed into one observation line)

To give you a feel for the numbers:

Original conversation (~5,000 tokens):
User: "What's the weather in SF?"
Tool: {"location": "San Francisco", "temp": 65, "conditions": "sunny" ...1k JSON}
Agent: "SF is currently 65°F, sunny"
User: "How about tomorrow?"
Tool: {"location": "San Francisco", "temp": 68, ...1k JSON}
Agent: "Tomorrow: 68°F, partly cloudy"

Compressed observation (~150 tokens):
🟡 2026-03-02 User checked SF weather
  - Today: 65°F sunny
  - Tomorrow: 68°F partly cloudy

Compression ratio: 33x. The more tool calls, the greater the compression benefit.

Data

LongMemEval 94.87% (GPT-5-mini)—current SOTA. For comparison, on the same benchmark, GPT-4o with Mastra scored 84.23%, while traditional RAG with GPT-4o only scored 80.05%.

Even more notable is the scaling characteristic: from GPT-4o (84.23%) to GPT-5-mini (94.87%), Mastra’s score jumped over 10 percentage points. The stronger the model, the greater the benefit of compressed memory.

Observational Trade-offs

Strengths:

  • Zero infrastructure—no Vector DB, no Graph DB, no external systems needed
  • Deterministic—same observation notes produce the same results every time (unlike retrieval, which has randomness)
  • Debug-friendly—just read the Observation block to see what the Agent “remembers”
  • Lowest cost—prompt caching (most providers offer 4-10x discounts) + zero retrieval overhead

Costs:

  • Synchronous blocking—conversation pauses when Observer triggers, until compression completes (async mode is in development)
  • Compression is lossy—the Observer might compress ten failed API calls into “attempted API calls, failed.” Fine for daily conversation, but if your Coding Agent is debugging, those ten error traces are the clues you need—compressing them away means genuine “amnesia”
  • Not suitable for large knowledge bases—can only compress conversation history, can’t replace document corpus RAG
  • Single-conversation only—no cross-user, cross-Agent shared memory mechanism
  • Multi-session ceiling—LongMemEval’s multi-session sub-score is only 87.2%, a clear weakness

Head-to-Head Comparison

Benchmark Comparison

BenchmarkMem0 (Graph)Zep (Temporal)Letta (OS)Mastra (Observational)
LOCOMO68.5%75.1%†74.0%‡—
LongMemEval—71.2%—94.87%

† Zep re-ran LOCOMO and found configuration issues in Mem0’s original evaluation (wrong user model, improper timestamp handling) ‡ Letta’s result using basic filesystem operations, not Mem0 integration

Important caveat:

These benchmarks can’t be directly compared across the board—each team tested different task types, models, and configurations. And the benchmarks themselves are controversial:

  • LOCOMO’s problem: Conversations average only 16k-26k tokens, within modern LLMs’ context windows. Zep found that stuffing the full conversation directly into context (without any memory system) scored ~73%—higher than Mem0’s 68.5%. This raises the question of whether LOCOMO actually tests “memory” at all.
  • LongMemEval is currently the more rigorous benchmark (averaging 115k tokens), but only Zep and Mastra have run it.

There’s an insight worth pausing on here: In 2026, with context windows reaching 1M or even 2M tokens, brute-force context coverage is often more effective than elegant retrieval. This also explains why Mastra’s Observational approach—compressing everything and stuffing it into context—achieves SOTA on LongMemEval.

The trend is still clear: Observational leads in long-conversation memory, while Graph-based has the advantage in structured knowledge and cross-session scenarios.

Architectural Philosophy Comparison

DimensionGraph-basedOS-inspiredObservational
Memory StorageExternal DB (Graph + Vector)Tiered (Core + Archival + Recall)Inside context window
Memory ManagerExternal pipelineThe Agent itselfBackground Agent
RetrievalHybrid searchAgent-initiated searchNot needed (everything in context)
InfrastructureHigh (Graph DB + Vector DB)Medium (Agent Runtime)Low (just LLM)
Cross-sessionNative supportNative supportWeak (compression is per-conversation)
Cross-userNative supportShared blocksNot supported
Temporal reasoningZep’s strengthLimitedLimited (relies on date markers)
ScalabilityHigh (DB scales)MediumBounded by context window
DebuggingInspect graphRead core memoryRead observation notes

Cost Comparison (estimated for 50-turn conversation)

ItemGraph-based (Mem0)OS-inspired (Letta)Observational (Mastra)
Ingestion LLM calls50 × 2 calls1 call per memory op~2 calls (Observer + Reflector)
Retrieval50 × hybrid searchAgent searches on demand0 (everything in context)
External DBGraph DB + Vector DBVector DB (archival)None
Prompt caching benefitLow (context differs each time)Medium (core memory is stable)High (observation block is stable)

Decision Framework

After all this architecture talk, let’s get to the practical question: which one should you use?

Scenario 1: Long-term Personal Assistant (remember user preferences, history)

Recommendation: Mem0 or Letta

Needs cross-session memory, user profile management. Mem0’s structured knowledge graph excels at “remembering facts,” Letta’s self-editing excels at “remembering behavior patterns.”

Scenario 2: Coding Agent (remember project context, coding style)

Recommendation: Letta Code or Observational

Letta Code’s Skill Library was designed exactly for this. If you don’t need cross-session memory, Mastra’s zero-infrastructure approach is simpler.

Scenario 3: Customer Service Bot (many users, audit requirements)

Recommendation: Zep

The temporal knowledge graph’s bi-temporal model natively supports audit trails. It can answer compliance questions like “what did the user say three months ago?”

Scenario 4: High Throughput, Cost Sensitive

Recommendation: Observational

Zero infrastructure + prompt caching = lowest cost. But accept the multi-session limitations.

Scenario 5: Enterprise Knowledge Management

Recommendation: Mem0 (managed) or Zep (managed)

Need SOC 2, HIPAA compliance, multi-tenant support. Both offer managed services.

Quick Decision Tree

Does your Agent need cross-session memory?
├─ No → Observational (simplest, cheapest)
└─ Yes
   ├─ Need temporal reasoning (facts change over time)?
   │  └─ Yes → Zep (temporal KG)
   └─ No
      ├─ Does the Agent need to learn autonomously?
      │  └─ Yes → Letta (self-editing memory)
      └─ No
         └─ Mem0 (structured extraction, fastest to ship)

Conclusion: No Silver Bullet, but No Longer Unsolvable

After researching all three schools, I’ll be honest—none of them made me think “this is the one”:

  • Graph-based has beautiful structure, but running an extraction pipeline every conversation adds up in cost
  • OS-inspired has a cool vision, but Agent self-management isn’t quite there yet—even Letta found that filesystem operations beat graph memory
  • Observational has the best numbers, but falls short the moment you need cross-session memory

This will probably converge toward some kind of hybrid—Observational compression within sessions, Graph persistence across sessions. But that’s a future problem.

The practical move right now is simple: look at your scenario, pick one from the decision tree above, ship it, then iterate. The perfect solution doesn’t exist, but waiting just means your Agent keeps forgetting.

If you remember only one thing:

RAG is no longer the only answer. In 2026, AI Agent memory has three serious solutions, each crushing pure RAG in its sweet spot. The only question is whether you’re willing to try.

The next article will dive deep into Mem0’s architecture—how the extraction pipeline works, Graph Memory implementation details, and the real methodology behind that 26% accuracy boost from the paper.


References

  1. Mem0: Memory Layer for AI Agents (arXiv:2504.19413) — Mem0 core paper, source of the 26% accuracy boost data
  2. Zep: A Temporal Knowledge Graph Architecture for Agent Memory (arXiv:2501.13956) — Zep/Graphiti paper, bi-temporal KG architecture details
  3. MemGPT: Towards LLMs as Operating Systems (arXiv:2310.08560) — Letta’s predecessor MemGPT, the original paper
  4. Mastra: Observational Memory — Observational Memory official blog
  5. Mastra Research: Observational Memory — LongMemEval 94.87% benchmark details
  6. Letta Code Announcement — Context Repositories + Terminal-Bench ranking
  7. Letta: Benchmarking AI Agent Memory — The “filesystem beats graph memory” research
  8. Mem0 Series A ($24M) — Mem0 commercialization + AWS partnership
  9. Zep: State of the Art Agent Memory — Zep official benchmark analysis
  10. Zep: Is Mem0 Really SOTA in Agent Memory? — Zep’s critique of Mem0 benchmark methodology

This is part of the “AI Agent Architecture in Practice” series. Previous: Cursor’s $29B Secret: The Deleted Shadow Workspace, Reverse-Engineered. Next: Mem0 Deep Dive—From arXiv Paper to Production