<!-- generated by build_articles.py — edit content/answers/agentic-memory-vs-rag.md instead -->
---
title: "Agentic memory vs RAG: what is the difference?"
canonical: "https://xerj.org/answers/agentic-memory-vs-rag"
updated: "2026-10-28"
source: "content/answers/agentic-memory-vs-rag.md"
---

# Agentic memory vs RAG: what is the difference?

**Short answer** (updated 2026-10-28): What is the difference between agentic memory and RAG? RAG retrieves evidence to inform generation, including documents or conversation history. Agentic memory retains information across tasks; RAG can be its retrieval step. Both depend on good search, so XERJ serves document search and agent memory from the same local binary.

**TL;DR**: RAG retrieves evidence for generation. Agentic memory keeps information across tasks and can use RAG to retrieve it. Both depend on search. XERJ serves document search and agent memory from the same local binary, so an agent uses one tool for both.

## Agent prompt

```text
Act as a coding agent. Read https://xerj.org/llms.txt, install XERJ, run xerj autoindex on this project folder for RAG-style retrieval, store two facts I tell you with POST /_memory/project, then answer one question using both the index and memory recall and cite where each part came from.
```

## Commands

### Command 1

Note: Install the single XERJ binary.

```sh
curl -fsSL https://xerj.org/get | sh
```

### Command 2

Note: The RAG side: index a folder of documents so the agent can search them.

```sh
xerj autoindex ./docs
```

### Command 3

Note: The memory side: the agent saves something it learned during the task.

```sh
curl -s -XPOST 'http://127.0.0.1:9200/_memory/project' -H 'content-type: application/json' -d '{"text":"The customer asked for weekly reports, not daily."}'
```

## The difference in one table

| | RAG | agentic memory |
| --- | --- | --- |
| data source | documents, raw history or other indexed records | retained preferences, events and decisions |
| what it holds | docs, code, tickets, data | preferences, decisions, lessons |
| changes during work | depends on the retrieval source | the memory workflow may add, update or delete |
| how it is read | search | search |

## Agentic RAG sits in between

Agentic RAG means the agent decides when and what to search, often in several rounds. Its sources can change during work. Persisting notes or history for later tasks adds a memory workflow; the two are compatible.

## Simple often wins

Two 2026 arXiv preprints evaluated specific conversational-memory tasks. One found a plain raw-history RAG baseline ranked first among the compared memory systems in six of seven settings. The other found no consistent advantage for explicit memory systems over strong raw-history retrieval.

These results motivate testing a raw-history baseline alongside transformed memory. Raw-RAG uses dense retrieval, reranking and a reader LLM; its results do not measure XERJ or its default lexical embedder.

## How XERJ does both

XERJ is the search engine for AI agents: a new way for AI to search for data.

- RAG side: `xerj autoindex <folder>` makes your files searchable.
- Memory side: `POST /_memory/{namespace}` saves a note and `_recall` finds it. Plain query recall is BM25.
- Both live in one local binary without a separate vector database. The lexical default needs no external model-provider key; secured node access uses a XERJ API key.

The default embedder is lexical feature hashing. For neural embeddings, start the node with `--embed-mode neural`. XERJ is single-node.

## Try it

Copy the prompt on this page into your coding agent. It indexes a folder, stores two facts and answers a question from both.

## FAQ

### Is agentic memory the same as RAG?

They overlap. RAG is a retrieval-and-generation technique; agentic memory is information retained across tasks. A memory system can use RAG to retrieve its stored notes or raw history.

### What is agentic RAG?

RAG where the agent decides when and what to search, often over several rounds, instead of one fixed lookup before the answer.

### Do I need both?

Often yes. Use RAG for docs, code and data you already have. Use memory for things the agent learns that are written nowhere else, such as a user preference.

### Is complex agent memory better than plain retrieval?

Not always. Two 2026 arXiv studies found plain retrieval over raw history often matched or beat more complex memory systems on their benchmarks.

### Can one tool do both?

Yes. XERJ indexes your files for search and also has a /_memory API for agent notes, in the same local binary.

## Evidence

- Is Complex Agentic Memory Always Needed? Naive RAG Is Stronger Than We Thought: a raw-history RAG baseline ranks first among the compared memory systems in six of seven benchmark-model settings. — [https://arxiv.org/abs/2610.30755](https://arxiv.org/abs/2610.30755)
- Do Conversational Agents Need Explicit Memory? finds only localized gains for explicit memory systems and no consistent advantage over strong raw-history RAG baselines. — [https://arxiv.org/abs/2610.24671](https://arxiv.org/abs/2610.24671)
- XERJ memory: POST /_memory/{namespace} stores, POST /_memory/{namespace}/_recall recalls with BM25 by default, each namespace is its own index. — `engine/crates/xerj-api/src/memory_api.rs`

## Related

- [What is agentic memory?](/answers/what-is-agentic-memory)
- [What is an MCP memory server?](/answers/what-is-an-mcp-memory-server)
- [How do I build RAG without a vector database?](/answers/rag-without-vector-database)
- [XERJ vs agent memory tools: Mem0, Zep, Letta and Cognee](/compare/xerj-vs-agent-memory-tools)
- [Should my agent call a search API or stand up Qdrant for persistent memory?](/compare/xerj-vs-vector-database)
- [What's a simple way to give an agent long-term memory on my laptop without Qdrant?](/answers/agent-memory-without-postgres-qdrant) (same intent: agent memory)
- [How can agent-memory links retain evidence?](/answers/evidence-for-agent-memory-links) (same intent: agent memory)
- [How do I give two agents private memory on one laptop?](/answers/private-agent-memory-namespaces) (same intent: agent memory)
