# Agentic retrieval and memory

> Retrieval and memory are how an agent knows things outside its context window. This topic covers retrieval as a loop the agent drives rather than a single lookup, the choices for where and how memory is stored, and the many cases where a plain retrieval step is all a system needs.

Page: https://schubergphilis.github.io/ai-training/topics/building-agents/retrieval-memory/
License: CC BY-SA 4.0, https://creativecommons.org/licenses/by-sa/4.0/

*Building agents* · topic `building-agents/retrieval-memory`

Retrieval and memory are how an agent knows things outside its context window. This topic covers retrieval as a loop the agent drives rather than a single lookup, the choices for where and how memory is stored, and the many cases where a plain retrieval step is all a system needs.

## Concepts

- **Agentic RAG loop**: Retrieval driven by the agent: it forms a query, reads what comes back, judges whether it answers the question, and reformulates, searches elsewhere or drills into a document before answering. Compared with one fixed search per question, it handles vague queries and multi-hop questions much better, at the cost of more calls and a loop that needs a bound. [glossary](https://schubergphilis.github.io/ai-training/glossary/#agentic-rag-loop)
- **Memory storage choices**: Where an agent's long-term memory lives and how it is found again: plain files the agent reads whole, key-value notes, a searchable index over text, a database queried by tool, or summaries folded into the system prompt. Each trades simplicity against scale and precision. Start with files the human can read and edit; add indexing when volume demands it. [glossary](https://schubergphilis.github.io/ai-training/glossary/#memory-storage-choices)
- **When basic RAG suffices**: Many systems need only the simple form: embed documents, retrieve the top matches for the question, put them in the prompt, answer. It is enough when questions are direct, the corpus is well chunked and latency matters. Reach for agentic retrieval only when evaluation shows failures on multi-step or ambiguous questions that a better index cannot fix. [glossary](https://schubergphilis.github.io/ai-training/glossary/#when-basic-rag-suffices)

## Links

- **Builds on:** [The agent loop and harness](https://schubergphilis.github.io/ai-training/topics/building-agents/agent-loop/), [Grounding and memory](https://schubergphilis.github.io/ai-training/topics/concepts/grounding/)
- **Leads to:** nothing yet
- **Competencies drawing on it:** [Builds a tool-using agent loop](https://schubergphilis.github.io/ai-training/competencies/building-agents/builds-agent-loop/)

## Lessons

- [Where an agent's memory lives](https://schubergphilis.github.io/ai-training/building-agents/agent-memory/) (explanation)
- [Retrieval as a tool the agent calls](https://schubergphilis.github.io/ai-training/building-agents/retrieval-as-a-tool/) (tutorial)

## Sources

- `AEC-05` [Memory and context: context engineering, memory kinds, memory versus RAG, context rot](https://lsimons.github.io/agent-engineer-course/05-memory-and-context/), Agent Engineer Course (course)
- `AEC-08` [Agentic RAG: the retrieve, evaluate, refine loop; when basic RAG is enough](https://lsimons.github.io/agent-engineer-course/08-agentic-rag/), Agent Engineer Course (course)
- `Academy building-with-the-claude-api` [Building with the Claude API](https://academy.claude.com/courses/building-with-the-claude-api), Claude Academy (course)
- `Academy claude-platform-101` [Claude Platform 101](https://academy.claude.com/courses/claude-platform-101), Claude Academy (course)
- `OpenAI Academy build-with-retrieval-augmented-generation-2v6xg` [Build with Retrieval-Augmented Generation](https://academy.openai.com/public/courses/build-with-retrieval-augmented-generation-2v6xg), OpenAI Academy (course)
