Agent memory vs RAG: the write path
RAG looks things up in a corpus someone else keeps. Agent memory also decides what to write, what to update and what to retire. Most memory uses RAG to read.
On this page
The difference between agent memory and RAG is the write path. RAG (retrieval-augmented generation) looks up passages in a corpus that someone else keeps, and puts them in the prompt. It changes nothing. Agent memory does that too, but it also decides what to write down while it works, what to update when something changes, and what to retire when it stops being true. So memory isn’t the opposite of RAG. Most agent memory uses retrieval to read. What makes it memory is that the agent writes it.
| RAG | Agent memory | |
|---|---|---|
| Reads | A corpus: docs, a wiki, a codebase | Notes the agent and you wrote while working |
| Who writes | People, or a pipeline that indexes their documents | The agent, during the session |
| Changes when | The source documents change and are reindexed | The agent learns, decides or finds something wrong |
| Old content | Replaced when the source is | Superseded or retired, ideally kept with a status |
| Typical failure | The wrong passage comes back | Noise gets saved, or something stale is believed |
| Needs | A search index | A search index, plus rules for writing |
What RAG is, exactly
RAG comes from a 2020 paper by Patrick Lewis and others. A language model was paired with “a dense vector index of Wikipedia”, searched with a neural retriever, and the passages it found were given to the model as it wrote its answer.
The paper calls that index the model’s “non-parametric memory”: knowledge kept outside the model’s weights. So in the original sense, yes, RAG is a kind of memory. It’s a memory the model reads and never writes. Wikipedia changed because its editors changed it, not because of anything the model said.
That’s still the shape today. The corpus is your product docs, a support knowledge base or a repository instead of Wikipedia, and the retriever might search by keywords, by meaning or both. But the content comes from outside the conversation, and the conversation leaves it as it was.
What agent memory adds: three choices
An agent with memory reads the same way, then makes three choices RAG never has to.
- What to write. Most of a session isn’t worth keeping. The cause of a bug that took an hour to find is. So is a preference you stated, or a choice you settled. The agent has to tell those apart from noise, during the work, without being asked each time.
- What to update. You decide to store dates in UTC, then a month later you change your mind. A memory that only appends now holds both, and retrieval may return either.
- What to retire. A fact about your toolchain was true in March and isn’t in November. Nothing contradicted it out loud. It just stopped being true, and it still reads as confidently as the day it was written.
These are the hard part. Retrieval is a well-studied problem with good tools. Deciding what’s current is not something a retriever can do, because the old note and the new one both match the query.
Is RAG a kind of memory?
RAG is read-only memory, in the paper’s own terms. For an agent, that’s useful but incomplete. It can tell the agent what your docs say. It can’t tell it what you decided yesterday, because nobody wrote that into the docs.
The question people usually mean is: “if I put my past conversations in a vector index, is that memory?” It’s a start. It gives recall: the agent can find something relevant from before. It doesn’t give a notion of what’s current. Every past message is equally true to a retriever, including the ones you later took back.
Do I need a vector database for agent memory?
You need a search index. It doesn’t have to be a separate vector database, and it doesn’t have to be the source of truth.
Memorinth, for example, keeps every memory, decision and fact as a Markdown file in a folder on your disk, called a cortex. The index lives beside the notes in a .memorinth/ folder: SQLite full-text search plus embeddings from a small local model. It’s built from the files and rebuilt when they change, so it never holds anything they don’t. How offline hybrid search works goes through it.
The point is general. Memory is a write problem first. Where the vectors live matters less than what gets written and whether old entries are marked as old.
How Memorinth handles the write path
Memorinth’s read path is ordinary retrieval. Agents call search_memory, which ranks sections of notes by meaning and keywords. The app’s Ask feature is RAG in the plain sense: it searches your notes, then writes an answer that links each claim to its source.
The write path is where it does more, with a separate tool for each kind of note:
- What to write.
write_memorysaves something learned, a preference or a how-to.record_decisionsaves a choice with its reasons.add_factsaves one claim, and requires a source. In Claude Code, a stop hook asks the agent to consider saving if it changed files and saved nothing. - What to update. Decisions and facts are never edited. A change is a new note that supersedes the old one, which stays, marked
superseded. - What to retire. A fact is due for a recheck 180 days after it was last verified. The agent checks it against its source and renews it, corrects it or retires it.
Search then follows those statuses. Accepted decisions and current facts rank higher. Superseded and retired notes are left out of results unless the agent asks for history. That’s the step plain RAG can’t take, because it has no idea which of two matching passages replaced the other. Decisions and facts: ADRs for AI agents covers the two note types in full.
When RAG alone is the better choice
Memory isn’t free. An agent that writes can write the wrong thing, and then act on it in every later session. RAG avoids that whole class of error, and it’s the better choice when:
- The knowledge already has an owner. Product docs, a support knowledge base, a policy library. People keep them right, and an agent writing its own copy would only drift from them.
- Sessions are independent. A support bot answering one question at a time may not need to remember the last customer, and often shouldn’t.
- You need to audit every answer against a fixed source. A read-only corpus is easier to review than notes an agent wrote.
Memory earns its place when the work spans sessions and the knowledge is made during it: a codebase you and your agents change every day, where the reasons behind a choice exist nowhere but in the conversation that made it.
If you add it, read what your agents write. A wrong memory is worse than a missing one, and a few notes that say something the code can’t are worth more than many that repeat it.
Next
How agents use it shows a session from the briefing to the save, and Memory what a saved note looks like. For the lifecycle, read Decisions and Facts.