The context window is where the model works right now — fast, immediate, temporary, and bounded. It's the agent's working memory, nothing more.
RAG is how relevant information gets fetched into that window — a retrieval technique.
Memory is the persistent state that outlives the session. Memory uses RAG to retrieve, and always lands in the context window — but it's the same as neither.
Three words, constantly confused
Memory, context, and RAG get used almost interchangeably, and that imprecision causes real architectural mistakes. They're related but distinct: the context window is where information lives while the model works, RAG is a technique for fetching relevant information, and memory is the persistent state that outlives any single request. Memory often uses RAG to do its job, and always ends up in the context window — but it isn't the same as either.
The context window is working memory, not memory
The context window holds what the model can see right now. It's fast and immediate but temporary and bounded — it's the agent's working memory, and nothing more. Anything not in it is invisible to the model, and everything in it vanishes when the session ends. Persistent memory exists precisely because the context window can't be the place knowledge lives long-term.
RAG is how memory gets retrieved
Retrieving relevant memories for the current moment is, mechanically, a retrieval problem. You embed memories, store them, and at query time find the ones most relevant to what's happening now — exactly the RAG pipeline. Memory retrieval is RAG applied to the agent's own past rather than to a document corpus.
The difference is what sits in the store. Classic RAG retrieves from a fixed body of documents. Memory retrieves from an evolving record of the agent's own experience — a store that grows, changes, and must be curated as the agent lives. Same retrieval mechanism, different and more dynamic source.
RAG retrieves from a fixed corpus.
Memory retrieves from a living past.Free Agent Memory Quick-Start — the four kinds of memory and the whole loop (store, retrieve, reflect, forget) on a few pages. Download it free.
Memory is the persistent state
Memory is the whole discipline: deciding what to store, how to store it, when to retrieve it, how to keep it accurate as it grows, and when to forget. RAG is one component of that — the reading step. The context window is where the result lands. Memory is the system that spans all of it and persists between sessions.
A quick test to keep them straight
When you're unsure which of the three you're dealing with, ask where the information lives and how long it survives. If it exists only for this request and vanishes after, it's the context window. If it's a technique for fetching relevant information into that window, it's retrieval. If it persists across sessions and represents accumulated state, it's memory. The test tells you which layer owns the problem you're debugging.
Going deeper? AI Agent Memory: The Complete Guide is the full reference — 41 pages, 15 chapters, 5 appendices, with a worked support-agent example and a 30-day adoption path. Get the guide.
FAQ
What's the difference between memory and the context window?
The context window is temporary working memory — what the model sees right now, wiped when the session ends. Memory is persistent state that outlives sessions. Memory feeds the context window, but isn't the same as it.
Is agent memory just RAG?
No. Memory uses RAG for retrieval — the reading step — but also covers writing (deciding what to store), consolidation, and forgetting, which RAG doesn't. And memory retrieves from the agent's evolving past, not a fixed document corpus.
How do memory, context, and RAG work together?
Memory is the persistent store. RAG is how relevant memories are retrieved from it. The context window is where those retrieved memories land so the model can use them. Memory uses RAG to fill the context window.
Why not just make the context window bigger?
Bigger windows help but don't replace memory: cost grows with everything you resend each turn, models attend poorly to huge contexts, and the window still vanishes at session end. Memory is persistent and selective by design.
Which one should I reach for?
Ask where the information lives and how long it survives. Vanishes after this request → context window. A technique to fetch relevant info → RAG. Persists across sessions as accumulated state → memory.
Top comments (0)