Brain Docs
Learn

Why memory exists

Why agents forgetWhy a bigger window doesn't fix itWhy RAG isn't memory

What a memory is

What a memory isThe statement kindsWhen facts collide

How it answers

How recall decidesDecay and retention

Using it well

What to write, and what not to

Reference

Brain/Docs
✦ ASKBrain on GitHubDashboard
LearnWhy RAG isn't memory

Why RAG isn't memory

A text chunk has no subject and no validity interval, so two chunks can never disagree — and the four places a vector database's model is the wrong shape for an agent's memory.

PURPOSE

RAG and memory both "fetch relevant things and put them in the prompt." The difference is in what gets stored, and it decides what each can ever do.

Different units, different ceilings

RAG stores documents, split into chunks, embedded. The question it answers is "which passages resemble this query?"

A memory layer stores observations — claims about a subject, valid over an interval, traceable to where they came from. The question it answers is "what do I currently know about this subject?"

A document chunk
A typed memory
What it's about
Nothing in particular — it's a span of text
A specific subject, named and resolved to a stable identity
When it's true
No concept of time beyond an ingest date
Valid from, valid until — when the claim held, not when it was written
Where it came from
A file path, maybe
Evidence linking back to the source memory, with a confidence
Can two of them disagree?
No — there is nothing to compare
Yes — same subject, same predicate, different object

The structural claim

That last row is the whole argument, so it's worth stating precisely:

Chunk-based retrieval is structurally incapable of detecting contradiction — a text span has no subject–predicate structure to collide on.

Not "doesn't yet." Can't. The limitation is not that embeddings are imprecise — a perfect embedding model would not help, because the missing thing is a field, not accuracy. Give a vector store these two sentences:

Priya manages the billing platform team.
Priya moved to the platform team in June and no longer manages billing.

Both are excellent matches for "who manages billing?" The first may well rank higher, because it's shorter, more on-topic, and contains the query terms more densely. Similarity has no opinion about which is true now. There is no embedding of recency, and no field where the second could say "I replace the first."

So the stale answer wins, and nothing in the system registers that anything went wrong.

Decompose the same sentences into (subject, predicate, object, interval) and the collision becomes mechanical: same subject, same predicate, overlapping intervals, different object → one supersedes the other.

What the extra fields buy, and what they cost

The typed record is not free. Against a pure-vector store it costs schema authoring and roughly 2× the metadata, and that is the honest price of entry. What it buys is four capabilities that are not "better retrieval" but different questions:

CapabilityThe question it answers
Bi-temporal validityWhat did I believe about Alice on 3 March?
Structured filtersPreferences only, confidence ≥ 0.7
Entity-anchored retrievalTell me everything about Alice — not "about text resembling Alice"
Supersession vs contradictionDid this change, or do two sources disagree?

Every one of those is unanswerable over chunks, in the strong sense: not "answerable badly" but with no field to evaluate the predicate against. A similarity score cannot be filtered by a confidence it doesn't have, and "everything about Alice" over an embedding index means "everything that reads like Alice", which is a different set containing different people.

Four places the vector-database model is the wrong shape

The reasonable follow-up is: vector databases are evolving — why not add this on top of Qdrant, Milvus or Weaviate? They are excellent, and the answer isn't that they're deficient. It's that a memory layer built on a vector-search-first architecture is always a guest in someone else's house, in four specific ways.

OptionTypeDefault / Env
The query modelsearch(vector, k, filter)

That is the surface a vector database exposes. A memory layer needs recall(cue, scope, confidence), plan(start, goal), reason(observation) — and these don't translate into search-plus-filter without losing structure. Confidence calibration, for instance, depends on the salience distribution and the embedding model's own calibration: internal facts the vector database doesn't expose because it has no reason to.

The write modelyou bring the vectors

A vector database assumes the application already produced the embedding. Owning embedding is what makes deduplication by semantic content, automatic re-embedding on model upgrade, and text-keyed caching possible at all. Hand the vector in and all three become the application's problem — see the embedding lifecycle bill.

The consistency modelmetadata as a sidecar

A memory's vector, its salience, its session and its outgoing edges have to be written and read atomically, or the agent observes incoherent intermediate states. Vector databases treat metadata as a companion to the vector rather than as co-equal state under one transaction.

The performance modelbatch vs hot path

Vector databases optimise for batch ingestion and analytical queries: build a corpus, search it, refresh occasionally. Agents do single-item writes and single-cue reads on the hot path, hundreds of times a second per space. Different target, different working set, different durability needs.

None of that makes a vector database the wrong tool. It makes it the wrong top of the stack: a vector index is an excellent component underneath a memory database, which is exactly where Brain puts one.

Where the adjacent systems sit

Concretely, across the category:

OptionTypeDefault / Env
Pure vector storesPinecone, Weaviate, Chroma, Qdrant, Milvus

Excellent filtered ANN search with rich metadata. Their primary abstraction is the collection of vectors, so "Alice prefers dark mode" is a string with a similarity score. Memory operations, salience, decay and consolidation are out of scope by design — the cognitive layer is assembled by your application.

Text-layer memoryMem0

Stores text with memory operations over it, but no typed graph — so contradiction stays structurally undetectable for the same reason it does in RAG.

Graph-backed memoryZep / Graphiti

Has a graph layer, and takes an external graph database as a dependency to get it — which puts you back in the multi-store consistency problem the integration tax describes.

The distinction to hold onto isn't quality — these are good systems — it's what the primary abstraction is. When it's the vector collection, structure is something you add on top. When it's the agent's memory, the vector index is an internal detail.

The clearest test

Skip the taxonomy and ask one question about your own code:

Can you describe what you want as "top-k similar vectors with this filter"?

If yes, use a vector database — you will get a better-engineered, better-scaled version of exactly that, and a memory layer is overhead. If instead you find yourself writing scaffolding for working-memory windows, episode boundaries, salience updates, plan trees or causal traces, you have started reimplementing a memory database inside your application, and the question is only whether you finish it yourself.

Where the memory frameworks sit

The other adjacent category is agent-memory frameworks — Letta (formerly MemGPT), Mem0, LangChain, LlamaIndex. These are closest to Brain in intent and furthest in position:

  1. They are application frameworks, not infrastructure. They run inside the agent's process, share its resources, and lean on whatever stores you point them at. They do not own the data path.
  2. They target a Python-first developer experience. Brain targets a wire-protocol-first integration: a separate process, like a database, that any language can talk to.

A fair mental model: Letta and Mem0 are to Brain as SQLAlchemy is to PostgreSQL. Useful at the application layer, and what they would talk to if a substrate existed at this level.

What a chunk also can't carry

Permission. Embedding similarity is blind to authorisation. A search for "staff engineer compensation" returns the comp band document because it is a perfect semantic match, and the fact that the asker is an IC is not represented anywhere in the vector. Post-filtering doesn't save you: the data already crossed into process memory, and the retrieval budget was already spent on rows you must now discard.

Truth that varies by asker. "What's our refund policy?" has a different correct answer for a support agent and an enterprise customer. One document; several truths; no place to put the distinction.

That second one has a structural answer in a memory layer and no answer at all in a chunk index. Identity resolution is scoped per tenant: the resolver's name, alias and fuzzy indexes are keyed under the owning (namespace, space), so "Priya Patel" in one tenant and "Priya Patel" in another are two entities with two ids that can never resolve into each other. The isolation is a property of how rows are keyed, not a filter applied after retrieval — which is the difference between "we don't return other tenants' data" and "other tenants' data was never a candidate.

The write side is where memory systems actually fail

A finding worth internalising before you build one of these: in a published 32-day production audit of a Mem0 deployment, 97.8% of stored memories were junk — hash duplicates, hallucinated profiles, and feedback-loop contamination where the system's own output was read back in as fact. Harvard's D3 research points the same way: aggressive pre-store filtering is essential to memory-system quality.

The lesson is not "that system is bad". It is that a memory layer's hardest problem is the write gate, not the ranker. Retrieval quality has a ceiling set by what you admitted, and no amount of fusion or reranking recovers from a store full of duplicates and self-generated claims. It is why what to write is the page in this section most likely to decide whether your deployment works.

It is also why "pass every turn through an LLM and let it decide what to save" is a pattern Brain refuses outright rather than ships as a default. It puts a model call on the write path — blowing the latency budget encode is held to — and the junk rate is the problem that approach has, not the solution to it. A tiered extractor that runs after the ack addresses the same need without either cost.

Choosing between them

The question is rarely "which is better" and almost always "which does this corpus want":

Reach for RAG when
Reach for memory when
The content is
Authored — docs, contracts, a knowledge base
Observed — what a user told you, what your system saw
It's about
A topic
A subject, with an identity you can resolve
Over time it
Gets revised, in place, by an author
Accumulates, and later claims disagree with earlier ones
The failure you fear is
Missing a relevant passage
Confidently returning something that stopped being true
Truth varies by asker?
No — one document, one meaning
Often — per tenant, per user, per role

If the right-hand column describes none of your content, you do not need a memory layer, and adding one is overhead with a maintenance cost.

Where RAG is still right

This isn't an argument against RAG. If your corpus is documentation, contracts or a knowledge base — authored content that doesn't contradict itself and isn't about a person — chunk retrieval is the correct tool and a memory layer would be overhead.

Authored content has a property observed content doesn't: somebody is responsible for keeping it consistent. When the refund policy changes, an author edits the document, and the old version stops existing. There is no contradiction to detect because the corpus never holds both. That is exactly the condition under which chunk retrieval's missing fields cost you nothing — and it is exactly the condition a conversation with a user never satisfies.

The two are complementary: RAG for what your organisation wrote, memory for what your agent learned. Most real systems want both, and Alongside your RAG is the recipe for routing between them.

In practice that means a single turn consults two sources and the prompt gets context from each: RAG over the company's documentation, which is static and bounded; memory for this agent's own accumulated state, which is dynamic and specific to one subject. They are not competing for the same slot. The routing question — is this a question about our docs, or about this user? — is usually answerable from the question alone, and where it isn't, asking both and merging costs one extra retrieval against a budget that has room for it.

What chunking itself destroys

One more thing worth separating out, because it is a property of the chunking step rather than of embeddings.

A chunk boundary is chosen by length, not by meaning. Split a transcript into 512-token windows and the sentence establishing who "she" refers to lands in chunk 4 while the claim about her lands in chunk 5. Both chunks embed fine. Neither carries the resolution, and retrieving chunk 5 alone gives you a claim with no subject.

The usual mitigations — overlapping windows, sentence-aware splitting, parent-document retrieval — all reduce the frequency and none remove the class. They are compensations for having thrown away structure that the source text had and the index does not keep.

Extraction inverts that order: resolve the referent first, attach the claim to a stable entity id, and the chunk boundary stops mattering because the subject no longer lives in a neighbouring span of text. The two sentences can be stored a year apart and still answer as one fact.

How the two are even measured

A last practical difference, and the one that catches teams migrating from a RAG mindset: the evaluation looks nothing alike.

RAG quality is an information-retrieval question — precision and recall at k over a labelled corpus. Memory quality is a temporal-reasoning question, and the benchmarks that exist for it reflect that: LongMemEval, LoCoMo and DMR test whether a system answers correctly after the facts have changed, across sessions, over time.

That matters because a system can score well on the first and badly on the second. Returning the passage most similar to the question is not the same skill as knowing that the passage stopped being true in June — and a retrieval metric computed over a static corpus cannot see the difference, because a static corpus has no June.

Try it

In the playground, run Relocation — a location fact, then a later one that replaces it. Open the Graph tab.

You'll see one subject with two claims and an explicit supersession edge between them. That edge is the thing a vector index has nowhere to put.

Then run Relocation a third time with a paraphrase of the second sentence. The memory count goes up and the claim count doesn't — which is the whole difference between an index of text and a record of what is true.

See also
What to write, and what not toWhen facts collideAlongside your RAG

Was this page helpful?

Why a bigger window doesn't fix it

Four limits that don't go away with capacity — cost, quadratic prefill, measured attention degradation, and a flat token sequence having no structure — plus the arithmetic of the alternative.

What a memory is

Four record types — memory, entity, statement, relation — the fields each carries, the eight edges that join memories to each other, and the one modelling decision users get wrong most often.

On this page

Different units, different ceilingsThe structural claimWhat the extra fields buy, and what they costFour places the vector-database model is the wrong shapeWhere the adjacent systems sitThe clearest testWhere the memory frameworks sitWhat a chunk also can't carryThe write side is where memory systems actually failChoosing between themWhere RAG is still rightWhat chunking itself destroysHow the two are even measuredTry it
Suggest an editOpen in Playground