RAG retrieves static documents by similarity; agent memory tracks evolving facts about users over time. The differences, where RAG breaks, and using both.
Reason for return
Additional comments
RAG retrieves static documents by semantic similarity; agent memory tracks evolving facts about users and the business over time, with provenance and the ability to know what's true now versus what was true before. They solve different problems and the best agents use both — but using RAG as your agent's memory is a common mistake that causes forgetting and contradictions.
| RAG | Agent memory | |
|---|---|---|
| Stores | Document chunks + embeddings | Entities, relationships, facts in a temporal graph |
| Retrieves by | Semantic similarity to the query | Relevance + recency + relationships, scoped to the user |
| Handles change over time | No — chunks are static | Yes — facts have validity windows; old facts are invalidated |
| Tracks provenance | Limited (which chunk) | Yes — every fact traces to its source episode |
| Best for | Static knowledge: docs, FAQs, policies | Stateful context: users, customers, decisions across sessions |
RAG is the right tool for grounding answers in a static body of knowledge— product documentation, support articles, policies, research. You chunk the corpus, embed it, retrieve the nearest chunks to a query, and the model answers from them. For “what does the docs say about X,” RAG is excellent and usually sufficient.
The moment your agent needs to remember a user across time, document RAG starts to fail:
This is why “just use RAG” produces agents that feel forgetful even with a big retrieval index.
Agent memory builds a temporal context graph from the agent's inputs: it extracts entities, relationships, and facts; records provenance and a validity window for each; and invalidates facts when they change. At query time it returns the relevant, token-efficient slice of what's true now (or what was true at a chosen time) for this user — not the nearest document chunks. That's what makes an agent consistent across sessions.
Robbie strongly favors Adidas shoes.
“I only wear Adidas shoes. I love them!”
The right architecture is usually layered: RAG for documents, agent memory for state. Ground factual answers about your knowledge base with RAG; ground the agent's understanding of the user, customer, and ongoing work with memory. Zep is built for the memory layer — it's the Context Lake for AI agents, managing, governing, and serving agent memory on temporal context graphs (built on the open-source Graphiti), with sub-200ms retrieval and benchmark-leading accuracy on LoCoMo and LongMemEval. It complements your document RAG rather than replacing it.
Match the question to the retrieval method:
If the answer depends on who the user is and what changed over time, it's memory. If it depends on a fixed corpus, it's RAG.
A production agent usually calls both — document RAG for knowledge, agent memory for state — and composes them into one prompt:
# 1) Document RAG: ground on the static knowledge base
docs = vector_store.similarity_search(user_question, k=5)
# 2) Agent memory: relevant, current facts about THIS user (Zep)
memory = client.thread.get_user_context(thread_id=thread_id).context
# 3) Compose one prompt — docs answer "what does the company know,"
# memory answers "what's true about this user right now"
prompt = f"""{memory}
Reference documents:
{docs}
User: {user_question}"""Memory keeps the agent consistent across sessions; RAG keeps it grounded in your documents. Neither replaces the other.
Related: What is agent memory? · What is a temporal knowledge graph? · Reducing LLM hallucinations · Research & benchmarks · AI agent memory guides
You can, but it breaks on change-over-time, relationships, and “similar vs. needed.” For multi-session, personalized agents, a temporal context graph is the right tool; keep RAG for static documents.
No. Both retrieve context, but RAG retrieves static document chunks by similarity, while agent memory retrieves evolving, provenance-tracked facts from a temporal graph scoped to the user.
Usually yes. Documents → RAG. User/business state over time → agent memory. Most production agents combine them.
Neither, necessarily. Zep provides the agent-memory layer (the Context Lake). It works alongside document RAG and integrates with any framework.
GraphRAG retrieves over a knowledge graph instead of flat chunks — but still typically over a static corpus. Agent memory adds time and provenance: user facts that change, with validity windows. Use GraphRAG for documents and a temporal context graph for user state.
No. A larger window lets you pass more text, but you still must choose what to pass — dumping everything adds cost, latency, and noise. RAG and memory both exist to select the right context, not all of it.
Not necessarily. Graph-based memory retrieval can stay in the same latency band as vector search — Zep reports sub-200ms p95 — while returning more precise, current facts and fewer tokens.