Blog·Learning

RAG vs agent memory: which one do you need?

Use RAG for knowledge that's the same for every user, and agent memory for what the agent should remember about each user over time. A decision guide with five questions and a worked support-agent example.

By Shardul Mane·8 min read

A blurred, grainy photo of a blue sky over a green hillside with a streak of white cloud, with the supermemory logo and the headline RAG and agent memory.

Use RAG when the answer lives in documents that are the same for every user, like policies, docs and product specs. Use agent memory when the answer depends on what happened with this user before and can change, like preferences, past decisions and open issues. Most production agents need both: RAG for what the company knows, and memory for what the agent knows about the person it's talking to.

For the definitions in depth, see memory vs RAG in our docs. This post helps you decide: five questions that sort most requirements, a worked support-agent example that uses both, and four tests that tell you whether your current RAG setup already covers memory.

Which one do you need?

Ask these five questions about each thing your agent has to know:

  1. Is the answer the same for every user? A refund policy or an API reference is. Use RAG over a shared knowledge base.
  2. Does it depend on what this user said or did before? "What size do I usually wear?" does. Use memory, scoped to that user.
  3. Can it change? A user switches plans, changes a preference or corrects a fact. Use memory that tracks updates, so the newer fact wins.
  4. Is it live business state? "Has my order shipped?" isn't a retrieval question at all. Call the system of record.
  5. Does it need to survive the session? If the next conversation, or another app, should know it, it belongs in memory rather than the context window.

The same answers as a table, with one more case at the end:

If your agent needs to... Use Why
Answer from policies, docs or specs RAG over a shared index The content is the same for everyone and changes on your schedule
Continue the current conversation The conversation history in the prompt Nothing has to outlive the session
Recall a preference or decision across sessions Agent memory It's about one user and has to persist
Know which fact is current after a change Agent memory with updates Similarity alone returns the old fact as readily as the new one
Check an order, a balance or a booking A call to the system of record Live state shouldn't come from a memory or an index
Follow relationships between things Structured records or a graph Some questions are about connections, not passages

The last row has its own guide: the Graph RAG tutorial builds a knowledge graph for relationship questions.

Do I need agent memory if I already use RAG?

Only if your RAG setup doesn't already do the things memory is for. RAG retrieves information to answer a request, and nothing stops you from indexing past conversations as documents. The original RAG paper even calls its document index the model's "non-parametric memory". What a document index doesn't give you on its own:

  • Scope. A shared index mixes everyone's conversations unless every query filters by user, every time.
  • Currency. If a customer asked for phone updates in March and email in May, both statements match a query about contact preferences, and the index can't tell which one is current.
  • Extraction. A transcript chunk holds whatever was said around a fact, and the fact you need may not be in the retrieved part.
  • Forgetting. Deleting what a user asked you to forget means finding every chunk that mentions it.

Our docs illustrate the currency problem with a sneaker shopper: they love Adidas, then their Adidas break, then they say they're switching to Puma. Weeks later, similarity search still returns "I love Adidas sneakers" as the closest match to "what sneakers should I buy?" (docs). A memory layer tracks that the preference was replaced.

If your RAG app passes the tests at the end of this post, a separate memory layer is optional. A bigger context window doesn't replace either one: it only holds what you send with one request.

Worked example: a support agent that needs both

Acme's support agent answers billing questions. In an earlier session, a customer told it they renewed their annual plan on October 3 and want updates by email. Today, in a new session, they ask:

Can I still get my money back for the renewal?

A good answer needs four things, from three places:

Part of the answer Where it comes from Why there
Annual plans can be refunded within 30 days of renewal RAG over the help center The policy is the same for every customer
This customer renewed on October 3 The customer's memory Only they said it, in an earlier session
They want updates by email The customer's memory, as a preference It should hold in every future session
The renewal payment actually went through The billing system Live state, checked before any refund

Here's the retrieval side with supermemory's v5 Python SDK, following the calls in our quickstart. The help center goes in one shared namespace as SuperRAG, which only chunks and indexes it, and each customer's conversations go in their own namespace on the default memory path, which also extracts facts and builds a profile:

from supermemory import Supermemory

client = Supermemory()  # reads SUPERMEMORY_API_KEY

# Shared knowledge: indexed for search, no memories extracted
client.add(
    "acme_support_kb",
    content="Annual plans can be refunded within 30 days of purchase or renewal. Monthly plans aren't refundable.",
    id="refund_policy_v3",
    task_type="superrag",
)

# This customer's history: the default memory path extracts facts and updates their profile
client.add(
    "customer_8812",
    content="user: I renewed the annual plan on October 3, but we might move to monthly.\n"
            "assistant: Got it. Do you want updates by phone or by email?\n"
            "user: Email, please.",
    id="ticket_4471",
)

# Weeks later, in a new session
question = "Can I still get my money back for the renewal?"

policy = client.search("acme_support_kb", query=question, search_mode="chunks", limit=3)
profile = client.profile("customer_8812").profile
history = client.search("customer_8812", query=question, search_mode="memories", limit=5)

context = "\n".join(
    [hit.chunk for hit in policy.results if hit.chunk]
    + [m.memory for m in profile.static + profile.dynamic]
    + [hit.memory for hit in history.results if hit.memory]
)
# Put `context` in the model's system prompt, and check billing before issuing a refund

Search is scoped to one namespace, so the policy and the customer's history are two calls, as in the docs' own example of combining them. Memories form in the background after an add, so a brand-new namespace can look empty at first. For a quick test, pass dreaming="instant" on the add, which bills one extra operation (quickstart).

Here's why the split matters:

  • With RAG alone, you'd index the old ticket next to the policy. Without a user filter on every query, another customer's renewal could surface, and "we might move to monthly" would be retrieved as readily as anything said later.
  • With memory alone, you'd store the refund policy in every customer's memory. It isn't about them, it goes stale in thousands of places when it changes, and it costs more to ingest.
  • With neither, the model would guess at the policy and ask the customer to repeat their renewal date.

The cost difference is real: SuperRAG ingestion is billed at a fifth of the memory rate per token, because it skips fact extraction (billing docs), so reference material belongs on that path. Current rates are on the pricing page.

How to tell whether your RAG app needs memory

Run the same four tests against your current setup and against one with a memory layer, using the same questions and histories:

  1. Correction. Tell the agent a preference, then change it in a later session. Does the new one win?
  2. Across sessions. End the session, start a fresh one and ask something that needs the earlier fact.
  3. Isolation. Ask the same thing as a different user. The fact shouldn't appear.
  4. Deletion. Ask the agent to forget the fact, then check that no answer can still use it.

Score answer correctness and source support separately from retrieval. An answer can be wrong even when the right passage was retrieved, because the failure was in context assembly or reasoning. Then add cost per successful task and latency. If your RAG app passes all four, keep it. If it fails corrections or isolation, that's what a memory layer is for, and the build vs buy guide helps decide whether to build one.

How supermemory handles both

One API covers the two paths. Documents ingested as SuperRAG are chunked, embedded and searchable as chunks only (SuperRAG docs). Content on the default memory path is also turned into memories, linked to earlier ones as updates, extensions or derived facts, and summarized into a user profile (graph memory docs). Search can return memories, chunks or both, inside one namespace per call. The product page walks through the engine, and the docs' comparison page has a cheat sheet for when plain RAG is enough.

Common questions

Is agent memory just RAG over chat history?

Partly. Retrieval is one step of memory, but memory also decides what to keep from a conversation, extracts it as standalone facts, replaces facts that change, scopes them to a user and forgets on request. RAG over raw transcripts does the retrieval step only.

Can I build agent memory on my vector database?

For a handful of preferences, yes: a table keyed by user can hold them, and you may not need semantic search at all. It gets harder once facts change, users span many sessions and apps, and deletion has to be reliable. AI memory vs vector databases separates what a database gives you from what the memory layer still has to do.

Does a bigger context window replace RAG and memory?

No. A context window holds what you send with one request, so nothing in it carries over to the next session unless you save it and send it again. Long prompts also have limits of their own: in Lost in the Middle, models used information at the start or end of a long input much more reliably than information in the middle.

Where do I start if I need both?

Index your shared documents first, since that's plain RAG and easy to test. Then add memory for the one cross-session behavior that matters most, such as remembering a preference, and run the four tests above. The RAG chatbot guide covers the retrieval side end to end.

  1. We dug into Claude Code's memory. Here's exactly how it worksLast month, our founder Dhravya Shah broke down how Instinct's memory works. We wanted to do the same for Claude, since that's where we spend most of our day.
  2. How AI memory actually works. A beginner's guideHow AI apps remember things between chats, why a bigger context window doesn't solve it, and the parts every memory system shares.
  3. We're open sourcing the company brain. Here's how we designed the multiplayer harnessCompany Brain is now open source. A walkthrough of the multiplayer harness behind its Slack experience, from proactivity and memory boundaries to approvals and recovery.
  4. Jev changes a lot in memory & context engineering. Here's exactly how.We tested Jev across reranking, chunking, observation, and harness decisions. Here is where fast decision models help memory systems, where they cost more, and where they still fall short.
  5. I reverse-engineered Instinct's memory. Here's exactly how it worksInstinct keeps its memory as git-tracked markdown files, found with grep rather than vectors. Here is the whole system as far as black-box probing can reconstruct it, and how to rebuild it on supermemory in about 60 lines.
  6. An update to supermemoryWe've discontinued the supermemory company brain and Nova. Everyone who was charged has been refunded, our MCP and plugins continue to run, and we're going all in on the memory engine.
  7. Scaling Conversations: How Adapta Grew Usage Without Losing ContextAdapta added Supermemory as a persistent memory layer so every conversation keeps its context — letting the team scale usage without losing the thread.
  8. How Chatarmin Ditched RAG and Went Memory-Only with SupermemoryChatarmin replaced a heavy RAG pipeline with Supermemory's memory layer — cutting average AI response time from 40s to 12s and token usage by 40–50%.
  9. SMFS: making agentic retrieval 55% cheaper AND more accurateWe launched SMFS.ai (Supermemory Filesystem) a few weeks ago, with a simple bet: We can redesign the filesystem specifically for agents, with special files, structures, and commands that it can use for it's tasks. Today, SMFS is used by hundreds of companies to power their agents.
  10. Introducing Dynamic Dreaming: supermemory now connects the dots, for you.Dreaming is magical. TLDR: We're launching Dynamic Dreaming in supermemory today, which automatically works if you're using supermemory in any way - API, OpenClaw, Hermes agent, etc.
  11. Dear reader, we just made supermemory insanely cheap... the Context CloudWhen I first started building supermemory, I had one goal: To build the best memory system for AI. I would talk to customers, and find out that memory was not the only thing they needed - They were all setting up 7-8 different vendors at the same time.
  12. Introducing @supermemory/tools v2.0.0Today we're releasing v2.0.0. This release unifies the API across all agents sdk integrations from AI SDK to Mastra, makes conversation identity a first-class concept, and ships with memory saving on by default.
  13. Solving the Precision-Recall Tradeoff: Search Result AggregationWhen you're building memory for AI, search is your foundational layer. The way search generally works is straightforward: the user defines a query, and then sets a limit (top-K) on how many search results they want returned. Usually, this is set to 10 or 20.
  14. OpenClaw Memory Problems: Why It Forgets and How to Fix It (2026)OpenClaw remembers by writing Markdown files in its workspace, so it forgets anything the agent didn't save. Why that breaks down, how the supermemory plugin recalls and saves on every turn instead, and how to install it, free on every plan.
  15. Stateful Coding Agents with Memory: Build Long-Running Agents (2026)We built a plugin for Claude Code and OpenCode that gives your coding agent persistent memory. It remembers your preferences, learns your codebase, and never loses context mid-conversation. The result is an agent you can run for months without starting over.
  16. Clawd / Molt bot's memory SUCKS. We gave it supermemory.I'm the founder of supermemory. Clawd/Molt bot is blowing up right now, with many, many use cases. I set it up, too, and have been using it through telegram. TLDR: just go to https://supermemory.ai/docs/integrations/clawdbot to set up supermemory for your clawd bot.
  17. Catch up with our UNFORGETTABLE Launch WeekOver the last year, one belief has guided almost everything we’ve built at Supermemory AI becomes meaningfully useful only when it remembers. Memory shouldn’t be something developers rebuild from scratch. It shouldn’t be fragile, expensive, or trapped inside a single tool.
  18. Empowering the Next Generation of Founders: Supermemory Startup ProgramIf there’s one thing we’ve learned while building Supermemory, it’s that most startups don’t fail because they didn't build features; they fail when infrastructure slows them down, or they built too slow.
  19. Building code-chunk: AST Aware Code ChunkingAt Supermemory, we're building context engineering infrastructure for AI. A huge part of that is dealing with code: ingesting repos, understanding structure, and making it searchable. The problem is that most code chunking solutions are terrible. We built code-chunk to fix this.
  20. Supermemory raises $3 million with the best memory engine for LLMsToday, I am excited to announce our first funding round to accelerate our mission of building an interoperable, scalable and reliable memory for LLMs and agents. Memory is one of the hardest challenges in AI right now.
  21. Mem0 vs Supermemory: Why Scira SwitchedScira AI moved its production memory layer from Mem0 to Supermemory. This is what failed, what improved, and how the team evaluated the two systems.
  22. Never Record Again: How Montra Uses Supermemory to Rethink Video CreationCampbell Baron, the founder of Montra, has been making videos since he was twelve. By thirteen, he was already doing brand work. Today, he’s betting on a very different future for creators: a world where recording is the exception, and most videos are generated from scratch.
  23. Unified Memory That Works Where You Work: Your Second Brain With SupermemoryHi everyone, I’m Dhravya, the founder of Supermemory. I want to start with a little story behind why this product means so much to me. You can also skip straight to what it is and how it works below.
  24. Supermemory just got faster on PlanetScaleWhat is Supermemory? Supermemory completes the missing part of the LLM puzzle: memory. Just as memory is crucial for human intelligence, it's essential for truly intelligent AI systems.
  25. Faster, smarter, reliable infinite chat: Supermemory IS context engineering.People are obsessed with prompts and prompt engineering. Sure, what you say is important, but what the model knows when you say it is the difference between a stateless text generator and an intelligent AI system. In short, context is the most crucial component.
  26. We solved AI API interoperabilityOne API to rule them all, One spec to find them, One library to bring them all and in the TypeScript, bind them. When we were building the Infinite Chat API, initially, we only supported the OpenAI format. This was fine, until a lot of our customers started asking for more.
  27. The Wow Factor of Memory - How Flow Used Supermemory To Build Smarter, Stickier ProductsOverview: Flow is a note-taking app built around a bold vision: to create a more personal, context-aware writing experience powered by AI. At the heart of this mission is memory.
  28. The UX and technicalities of awesome MCPsLast month, we launched the Supermemory MCP, mostly to test our own infrastructure and get some initial traction. It blew up. To my absolute surprise, the initial launch itself got half a million impressions (!!!). Then, we launched and got #2 on ProductHunt too.
  29. Architecting a memory engine inspired by the human brainLanguage is at the heart of intelligence, but what truly powers meaningful interaction is memory — the ability to accumulate, recall, and contextualize information over time. Large Language Models (LLMs) have mastered language, but memory remains their Achilles’ heel.
YOUR PRIVACY

Change or withdraw any time via Cookie settings in the footer. Read our cookie notice.