Skip to content

Agent Memory vs. memory middleware

Middleware. Mem0, Zep and Letta sit between the agent and its storage.
The cost. Each layer adds latency, cost and a consistency gap.
Agent Memory. Memory in the database itself, one transaction from the data.

THE LANDSCAPE

A category with one shared limit

Mem0

LLM-driven extraction and consolidation, with optional graph storage. Strong developer experience over a set of separate stores.

Zep

Long-term memory with temporal knowledge graphs and entity extraction. The structure arrives as a separate service with its own consistency model.

Letta (MemGPT)

A self-editing memory framework where the agent manages its own context window. Memory sits outside the transactional boundary.

THE COMPARISON

A layer between the agent and its data. What the middleware adds, and what the database already holds.

Consistency

Agent Memory

Memory middleware

Atomicity
One transactionMemory and state commit together in the database.
Two systemsMemory commits in the middleware, state in the database, separately.
Round trips
One hopThe agent reads and writes memory straight in the database.
Two hopsEvery memory operation goes through the service, then the store.
Operations
Services to run
The databaseMemory is a set of tables and indexes in the database you already run.
One more serviceA memory service to deploy, scale and secure beside the database.
Permissions
One modelRBAC and record-level permissions cover memory and data alike.
Two modelsOne permission model for memory, another for the data it refers to.

THE ALTERNATIVE

Memory inside the database

HOW IT WORKS

Recall and remember in one round trip. The agent reads its memory and writes the outcome in the same transaction.

1BEGIN TRANSACTION;
2
3-- Recall what the agent knows about this user
4LET $context = SELECT fact, valid_from FROM memory
5 WHERE agent = agent:support AND user = user:jaime
6 ORDER BY valid_from DESC LIMIT 5;
7
8-- Remember the outcome, beside the data it concerns
9CREATE memory SET
10 agent = agent:support,
11 user = user:jaime,
12 fact = "Moved to the Memory+ plan",
13 source = conversation:4471,
14 valid_from = time::now();
15
16COMMIT TRANSACTION;

TRUSTED BY

Enterprise teams building on SurrealDB

Memory middleware,answered

Mem0 and Zep are middleware layers between the agent and its storage, abstracting over a vector store, a document store and a graph engine that stay separate. Agent Memory is built into SurrealDB, so memory and application data share one transactional store with no consistency gap between them.

THE PLATFORM

Everything an application and its agents know. Five surfaces, one engine.

IN PRODUCTION

Trusted at scale. Samsung, Nvidia, Verizon, Tencent, and Walmart run on SurrealDB.

14,000+

Developers building on SurrealDB Cloud

4M+

Developers building on SurrealDB worldwide

FROM THE TEAMS

SurrealDB gives us a foundation where we can unify semantic search, knowledge graphs, and AI-driven decision making without stitching together multiple systems. Collapsing responsibility into SurrealDB has become our default engineering posture.
Justin Foley

VP of Engineering, Later

GET STARTED

Memory without the middleware. Agent Memory keeps memory in the database: one transaction, one permission model, one service to run.

ISO 27001
AICPA SOC 2 Type 2
Cyber Essentials
GDPR
Cyber Essentials Plus
SurrealDB

The context and memory layer for AI agents

Database. Graphs, vectors, documents and relational data in one engine, in a single ACID transaction.
Agent Memory. Connects and retrieves context wherever your data lives, every fact carrying its source.
Cloud. Fully managed, in the cloud provider and region you choose.

Explore with AI

Copyright © 2026 SurrealDB Ltd. Registered in England and Wales. Company no. 13615201

Registered address: 3rd Floor 1 Ashley Road, Altrincham, Cheshire, WA14 2DT, United Kingdom

Trading address: Huckletree Oxford Circus, 213 Oxford Street, London, W1D 2LG, United Kingdom