AINave
Blog

Agent memory: we traced one fact through the code of 5 memory systems

I changed the location on a scraping job, and a few days later my agent went back to the old one. That is a memory problem. So we read the code of 5 open-source memory systems and followed one customer fact through each: who saves it, what it costs, how it comes back and what stays after delete.

Ramit Koul · 19 min read
Ask AI about this post
Agent memory: we traced one fact through the code of 5 memory systems

The short version

What it is
Notes the agent can read in a later session. The model's weights don't change.
What we did
Read the code of 5 open-source memory systems on Nov 27 and 28, 2026 and followed one customer fact through each. Nothing was run.
Cost of a write
From 0 extra model calls per write in Hermes Agent and Letta to 1 call with a 7,606-token prompt in Mem0.
Changed facts
Mem0 keeps both. Graphiti puts an end date on the old one. In Hermes Agent, Agno and Letta the model decides.
Delete
In 4 of the 5, deleting a memory leaves the text in a transcript, a history table or git history.
My view
A few files and the database you already have are enough. I don't think you need a separate memory product.

Tools in this post

So, I gave one of my Hermes agents a simple job. Find the companies that are hiring right now in one location. It went well for a few days. Then I changed the location, and that also went fine for a few days. After 2 or 3 days, it started scraping companies from the old location again.

That is a memory problem. The agent had an old fact and a new fact, and it went back to the old one. My Hermes agents also read my email and work as the support desk for my products, so the same kind of mix-up can happen in front of a customer. The model itself remembers nothing. Every session starts from zero, and whatever the agent knows has to be handed to it again by something outside the model.

Agent memory is what everybody is selling for this. On November 6, Anthropic published a long post on how it thinks agent memory should be built, and there is a whole category of memory products now. So for this post we did 2 things. We checked the published numbers at their sources. And we read the code of 5 open-source memory systems and followed one customer fact through each of them. What gets saved? What does saving it cost? And when the customer says "delete it", what is still there?

What agent memory is

Agent memory is nothing but notes that the agent can read in a later session. The model's weights don't change. Something gets written down outside the model, and something puts it back into the prompt next time. There is research on training memory into the weights, like the Meta FAIR work in our Nov 20 tech news edition, but none of the 5 systems in this post do that.

People mix it up with 3 other things, so here is how we use the words in this post:

  • The context window is what the model can see right now, inside one session. When the session ends, it is gone.
  • Compaction is a summary that replaces old messages when the window fills up. It keeps one long session going, and Anthropic's post leaves it out of memory for that reason.
  • RAG is search over documents that somebody else wrote. Memory is written from the agent's own conversations.

Anthropic's post splits memory into 4 layers. At the bottom are transcripts, the searchable log of every session. Above that are notes, the things the agent chose to write down. Then come representations built from the notes, like a wiki that the agent maintains. At the top is injected context, a small amount that is loaded into every session with no search at all.

The post also describes a clean-up pass it calls dreaming. Dreaming is nothing but the agent going back over old transcripts and notes when no user is waiting, so it can fix wrong notes and merge duplicates.

Four stacked layers of agent memory. From the bottom: transcripts, a searchable log of every session. Notes the agent chose to write down. Representations built from notes, such as a wiki. Injected context, a small file loaded into every session. The lower three are searched when needed and the top one is always loaded. A side arrow labeled dreaming shows an offline pass that reads transcripts and corrects the layers above.
Our drawing of the 4 layers described in Anthropic's Nov 6 post.

Every system below is some mix of these 4 layers.

One fact, 5 memory systems

Let's take one small example and keep it for the whole post. It is my location problem in another form: a fact changes, and the agent has to notice. A customer talks to your support agent in 3 sessions, and then asks for one more thing.

  1. Session 1: "I'm on the Free plan."
  2. Session 2, a week later: "We upgraded to the Team plan last week."
  3. Session 3: "Which plan am I on?"
  4. Later: "Delete everything you know about me."

We followed this through the code of 5 systems as it stood on November 27 and 28, 2026, with default settings. Hermes Agent is the one I run. Agno is the framework AINave's own agents are built on. Mem0, Graphiti (the open-source engine behind Zep) and Letta (the project that started as MemGPT) are 3 of the best-known memory projects.

SystemWho saves the factExtra model calls to save itThe old "Free plan" factHow it gets back into the promptAfter "delete"
Hermes AgentThe agent, with a memory tool0 per write, plus a background review every 10 user turnsOverwritten or kept. The agent decidesAlways loaded, capped at 2,200 + 1,375 charactersThe transcript stays in SQLite
AgnoA memory manager, if you turn it onAt least 1 on every runThe model is told to update it in placeEvery memory for that user, with no capThe transcript stays in the sessions table
Mem0Your code calls add()1, with a 7,606-token prompt, plus at least 2 embedding callsKept. Both facts are storedYour code runs a search, 20 results by defaultThe text stays in a history table
GraphitiYour code calls add_episode()At least 2, and more when there are older facts to compareKept, with an end dateYour code runs a search, 10 facts by defaultNo call for one person. You clear a whole group
LettaThe agent edits Markdown files and commits them0 per write, plus a reflection pass when the conversation is compactedEdited in the file. The model decidesTop-level files and folder indexes are always loadedOld versions stay in git history

The call counts come from reading the code with default settings. We ran none of it.

Hermes Agent: 2 small files

We read Hermes Agent earlier for our post on agent harnesses. Its memory is the simplest of the 5. There are 2 text files. MEMORY.md holds the agent's own notes and USER.md holds what it knows about you. They are small on purpose: 2,200 characters and 1,375 characters. Both go into the system prompt at the start of every session. There is no search over them and no vector database.

The agent writes to these files with a memory tool, so saving a fact costs no extra model call. If a file is full, the write is rejected and the agent is told to remove or shorten something first. So the cap is what forces the clean-up.

2 details we did not expect. Every 10 user turns, a background review goes over the conversation for things worth saving, and that review can only add. If it wants to change or remove a note, the edit waits for your approval. So if only the review notices the upgrade, you get "Team plan" next to "Free plan" until you approve the fix. I can't say that this is what happened with my scraping job, because we did not debug it. But it is one way an old fact stays alive. And Hermes is the only one of the 5 that scans every note for prompt injection patterns before saving it, because, as the code comment puts it, "a poisoned entry persists across sessions".

Old conversations are kept too, in a SQLite database with full-text search that the agent can query. This is also what "delete" misses. Removing a note rewrites the file, but the customer's original message stays in that database until you delete or prune the session.

Agno: off until you turn it on

Agno remembers nothing by default. The 2 flags that write memory start as off. When you turn on automatic memory, a memory manager runs on every run that has a user message, in the background, next to the main call. That is at least 1 extra model call each time, even when the user said nothing worth saving. By default it uses the same model as the agent.

What it saves goes into a database table, one row per memory, keyed by user. For our upgrade, the manager's prompt tells the model to update the existing row and to keep a note of what changed. So you would expect one row like "was on Free, upgraded to Team". But that is the model's decision. No code compares the 2 facts.

The read side is the part to watch. Every memory for that user goes into the system prompt on every run, with no limit on count or size. And there is no vector search over these memories. Agno does support pgvector, but in its knowledge base, which is the RAG side.

That matches how my own agents at AINave are set up. The knowledge base lives in pgvector tables, and the metadata and everything else lives in normal Postgres tables. I picked it because Agno recommends it that way. I also experimented and benchmarked it, and the results were pretty good.

3 more things from the code:

  • If you pass no user id, the id becomes "default". All your anonymous users share one memory.
  • The manager has a "clear memory" tool. It deletes the memories of every user, and not only of the one who asked. It is off unless you enable it.
  • Deleting one user's memories leaves their transcripts in the sessions table.

Mem0: it only adds

Mem0 is a library that your code calls. You call add() with the messages, and Mem0 makes 1 model call to pull facts out of them. The system prompt for that call is 7,606 tokens by our count, before your messages are added. Then it makes 2 embedding calls in a bare install, or 3 if the optional spaCy package is there, and stores each fact as a vector. Out of the box it needs an OpenAI key, and telemetry is on until you turn it off.

Now take the upgrade. The extraction prompt says "Your sole operation is ADD". So after session 2, Mem0 holds both facts: on the Free plan, and upgraded to Team. Nothing is updated and nothing is removed unless your own code calls update() or delete().

In session 3, your code runs a search and puts the results into the prompt. The search ranks by meaning and by keywords. We found no recency term in the scoring, so "Free plan" and "Team plan" can both come back, and the model has to work out which one is current. The stored dates are returned with each result, so you can sort by date yourself.

And delete. The vector is really deleted. But the deleted text is written to a history table first, and the last 10 raw messages for that user stay in SQLite as well.

Decay, where old memories fade with time, is refused by the open-source library.

Graphiti: old facts get an end date

Graphiti stores memory as a graph. A graph here is nothing but things (the customer, the Team plan) and the facts that connect them. Each fact carries dates: when it became true, and when it stopped being true.

So this is the one system with a built-in answer for the upgrade. A model call flags that "upgraded to Team" contradicts "on the Free plan". Then code puts an end date on the old fact. The old fact is kept, so you can still ask which plan the customer was on 2 weeks ago.

You pay for that on every write. One add_episode() is at least 2 model calls, and more when the new facts have older facts to be compared with. It also needs a graph database. The default is Neo4j, there is an embedded option too, and we found no Postgres option in the code.

2 things to know before you use it. The default search runs with an empty filter. It does not drop the ended facts, so in session 3 both plans come back and your code has to read the dates. And there is no call that deletes one person. The clean way is one group per customer, and then you clear that group. Call the same function with no group and it deletes everything.

Zep
ZepArtificial intelligence
Build fast and scalable LLM applications with Zep
View on AINave

Letta: the MemGPT project moved to files

Letta is the project that started as MemGPT. This was the surprise of the reading. The main Letta repository is now a pointer. Its README says "The current source code lives in letta-ai/letta-code", and it calls the old API server retired.

In the current code, memory is a folder of Markdown files inside a git repository. The agent edits the files with its normal file tools and commits them. In the local backend, the prompt is built from the last commit, so an edit that was not committed does not exist for the next session. Top-level files and folder indexes are always loaded, and a check before each commit caps one file at 20,000 characters and the always-loaded set at 65,536.

The clean-up pass is built in. A background agent, which Letta calls reflection or dreaming, runs when the conversation gets compacted and merges its changes back with git. Because it is git, every change has a history and can be rolled back. It also means a deleted note is still in that history.

We found no vector search over the memory files in this code. Search over past messages can use vector modes, but only on the cloud backend. Letta Cloud is the default backend and its server is not in the repository, so we cannot say what happens there.

Five cards showing what each store holds after the customer upgrades from the Free plan to the Team plan. Hermes Agent: one text file, where the agent rewrites the line or adds a second one. Agno: one database row that the model is told to update in place. Mem0: two rows, Free plan and upgraded to Team, both live. Graphiti: two facts, the Free plan fact kept with an end date and the Team plan fact current. Letta: a Markdown file edited and committed, with the old line still in git history.
The same upgrade in 5 stores, from our reading of the default code paths.

What the code reading adds up to

3 things stood out once all 5 were side by side.

First, the 2 systems where the agent manages its own memory ended up with capped files. Hermes and Letta both load files into every session up to a cap, 3,575 characters in Hermes and 65,536 in Letta, and reach the rest only when needed. Anthropic's post describes the same shape, and it says Claude Code loads only the first 200 lines or 25 KB of its MEMORY.md. The other 3 call a model when they write, and Mem0 and Graphiti also need their own store.

Second, the cost of saving one fact runs from nothing to a 7,606-token prompt. With Hermes and Letta, the write is a tool call inside a turn that is happening anyway, and the model is called again only in a background pass now and then. With Agno, Mem0 and Graphiti, every write is at least 1 more model call. On a support desk with thousands of messages a day, that becomes a line on the bill.

Third, delete rarely means gone. In 4 of the 5, the obvious delete leaves the customer's text somewhere else: in a transcript database, a sessions table, a history table or git history. Graphiti can remove everything, but only if you gave each customer their own group from day 1.

What the numbers say

Does memory help at all? Anthropic's post has the most detailed numbers, and all of them are its own measurements on its own models.

  • On one database task from the CL-Bench benchmark, Claude Opus 5.5 went from 0.655 to 0.838 mean reward when it could keep a memory folder between questions.
  • An older model barely moved. Sonnet 4.6 went from 0.330 to 0.364. When it was told to read its memory before answering and to test its theories, it reached 0.641. So the model has to actually use the notes.
  • More notes made things worse. Playing Pokémon Red, Sonnet 3.7 wrote 413 memory files and earned 1 badge. Claude Fable 5 wrote about 10 files and earned 4. That is one run each.
  • A wiki built by dreaming went from 13% to 48% on its test questions as the dreaming grew from 2 sessions to 128. But plain search over the same documents already scored 53%. Wiki and search together scored 61%.

The independent evidence is less kind. The CL-Bench paper itself, which tests agents across 6 domains, reports that "naive ICL outperforms systems dedicated to memory management". ICL is in-context learning, which here means the earlier questions and answers are simply left in the prompt.

And the product benchmarks are a mess. Most memory products quote a score on LoCoMo, a test of recall over long conversations. See what one product, Zep, has scored on it, depending on who measured.

Bar chart of 5 of the published LoCoMo scores for Zep. 58.44 percent, recalculated by Mem0's CTO. 65.99 percent in Mem0's paper. 75.14 percent, Zep's corrected figure. 84 percent, Zep's original claim, later withdrawn. 94.7 percent on Zep's site in November 2026. A marker shows 72.90 percent for the full conversation in the prompt with no memory system, from Mem0's paper.
One product, one benchmark, and 5 of its published scores. Sources are linked in the text below.

Zep first claimed 84%. Mem0's CTO recalculated that as 58.44%. Zep accepted there was an error ("we erred in how we calculated Zep's LoCoMo score"), corrected its number to 75.14% and disputed the 58.44%. Mem0's own paper had Zep at 65.99%. Zep's site now says 94.7%. Zep's post also carries an 80% figure at under 200 ms latency, so 5 is not even the full list.

That Mem0 paper has a row that matters more. Putting the whole conversation into the prompt, with no memory system at all, scored 72.90%. Mem0 scored 66.88%. In fairness to Mem0, the full-context run put about 26,000 tokens in the prompt against about 1,800 for Mem0, by our reading of the table, and it was much slower. So that paper shows lower cost and more speed. It does not show better answers.

And in August 2025, Letta scored 74.0% on the same benchmark with a plain agent that had the conversation in a file and 4 file tools: grep, search_files, open and close. The file was also embedded for semantic search, so it was more than text matching.

So a benchmark score cannot pick a memory system for you. Zep's post says LoCoMo conversations are about 16,000 to 26,000 tokens long, and that fits inside an ordinary context window today.

Where memory can hurt you

Memory also brings problems that an agent without memory does not have.

Old facts that look current

Mem0 keeps "Free plan" and ranks it without looking at dates. Graphiti returns ended facts unless you filter them. The Hermes background review cannot correct a note without your approval. In all 3 cases the agent can tell a paying customer that they are on the Free plan.

A bad instruction that gets saved

A prompt injection normally dies with the session. Once it is written to memory, it is loaded again in every session after that. Security researcher Johann Rehberger showed this on the ChatGPT macOS app in 2024: an instruction planted through a web page was stored in ChatGPT's memory and kept sending the user's conversations to his server in later chats. OWASP now lists memory and context poisoning in its top 10 risks for agentic applications. Of the 5 systems we read, only Hermes scans a note for such patterns before saving it, and that scan is a fixed list. So the stronger protection is the one from our post on permission modes: limit what the agent can reach, so a poisoned note cannot do much.

More copies of customer text

With Agno, Mem0 and Graphiti, every single write sends the customer's words to a model provider one more time, and the fact then lives in a second store next to the transcript. Hermes and Letta do the same in their background passes, only less often. If your customers can ask you to delete their data, list every place it lands before you turn memory on.

Do you need a separate memory product?

I don't think so. I have 2 reasons.

One. A few files and a database are more than enough. The LLMs are not that dumb now. Agents are very good at extracting the information they need.

Two. The memory layer is tightly controlled by the people who make the models, like Anthropic and OpenAI. It is inevitable that they will improve memory with their own implementation. So I don't think separate memory products like Mem0 or Zep will survive.

The code and the numbers above point the same way for most agents. So this is the order we would build it in.

  1. One small file that is always loaded, with a hard cap like Hermes has. Who the user is, what they asked you to remember, the rules that keep coming up. When it is full, something has to go.
  2. Transcripts that you keep and can search. A Postgres table with full-text search is enough to start. This is the bottom layer in Anthropic's design, and it is what Hermes and Letta both fall back on.
  3. A notes table keyed by user id, where a changed fact updates the old row and gets a new date. Make the user id required. Agno's "default" bucket shows what happens when it is optional.
  4. A clean-up job, but only when the notes start to rot. In Anthropic's test, 128 dreaming sessions put wiki plus search 8 points above plain search, so don't start here.

In fairness to the products, there are cases where one can still save you work:

  • You have many users with long histories and you don't want to write the extraction and the search yourself: a library like Mem0. Know that it only adds, and handle changed facts in your own code.
  • Your questions are about what was true at a given time, like billing or account history: Graphiti. You pay in model calls and you need a graph database.
  • The task is one-shot, like a single lookup or a single draft: skip memory completely.

How we did this

We cloned each repository and read the code at these commits: Hermes Agent 4957e8e and Agno 9a5bdbe (both November 28, 2026), Mem0 cae3d8c and Graphiti 343a7bb (both November 27), Letta 8816d3a (October 18) and Letta Code 1206859 (November 28). One AI reading agent went through each repository with the same list of questions, built around the 4 steps of the customer example. Every fact in this post was then checked again against the file and line it came from, and the links above go to those lines.

Nothing was run. This is a reading of default settings, and your configuration can change the behavior. Where we say we found no check or no search, it means our reading found none. For Agno we read the classic memory manager and not its newer opt-in learning package. For Letta we could read only the open code, and Letta Cloud's server is not part of it. Token counts use OpenAI's o200k_base tokenizer. The benchmark numbers are other people's measurements, given with their owners. Nothing in this post was benchmarked by us.

Sources

Facts last checked: Nov 28, 2026. These projects change every week, so check the commit before you rely on a detail.

Frequently asked questions

What is agent memory?

Notes that an agent writes outside the model and reads back in a later session. The model's weights do not change. Anthropic's Nov 6, 2026 post splits it into 4 layers: transcripts, notes, representations such as a wiki, and a small injected context that is loaded into every session.

Is agent memory the same as RAG?

No. RAG searches documents that somebody else wrote. Memory is written from the agent's own conversations. Many systems use the same search tools for both, which is why the two get mixed up.

What is dreaming in agent memory?

An offline pass where the agent rereads old transcripts and notes to fix wrong notes and merge duplicates. Anthropic uses the word in its Nov 6, 2026 post, and Letta Code runs a similar background reflection when a conversation gets compacted.

Do I need a vector database for agent memory?

Not to start. In the code we read, Hermes Agent and Letta Code keep memory in plain files, and Agno stores user memories as ordinary database rows. Mem0 and Graphiti use embeddings. Add vector search when you have too many notes or transcripts for keyword search.

Does Mem0 update or delete old memories automatically?

Not in the open-source library at version 2.2.1. Its extraction prompt only adds. A changed fact is stored next to the old one until your own code calls update() or delete().

Show 5 more questions

How does Hermes Agent memory work?

Two text files, MEMORY.md (2,200 characters) and USER.md (1,375 characters), are loaded into the system prompt at the start of each session. The agent edits them with a memory tool. Past conversations are kept in SQLite with full-text search.

Are agent memory benchmark scores reliable?

Treat them with care. Zep's LoCoMo score has been published as 58.44%, 65.99%, 75.14%, 84% and 94.7%, depending on who measured it and how. In Mem0's own 2025 paper, putting the full conversation in the prompt scored 72.90% against 66.88% for Mem0, at a much higher token cost.

Is Letta still MemGPT?

Letta is the project that started as MemGPT. As of November 2026 its main repository points to Letta Code, and the README calls the old API server retired. In Letta Code, memory is a set of Markdown files in a git repository.

How do I delete a user's data from agent memory?

Find every place it lands first. In 4 of the 5 systems we read, deleting a memory leaves text in a transcript database, a sessions table, a history table or git history. In Graphiti, give each user their own group so that you can clear it.

What does agent memory cost?

It depends on who writes. When the agent writes with a tool, as in Hermes Agent and Letta Code, a write adds no model call, and the model is called again only in a periodic background pass. Agno's automatic memory adds at least 1 model call on every run. Mem0 makes 1 model call with a 7,606-token prompt plus at least 2 embedding calls per add(). Graphiti makes at least 2 model calls per episode.

Keep reading

All posts

Find your next AI tool.

Browse 21,000+ AI tools, sorted by what they actually do.