Retrieval as memory
RAG, repurposed for agents: fetch the relevant slice of an external store into the working context, with citations so the agent can be checked.
Retrieval-augmented generation was invented for question answering: fetch relevant documents, put them in the prompt, generate an answer grounded in them. For an agent it does double duty — it is also the mechanism that turns semantic and episodic memory into working memory. The vector store is the library; retrieval is the act of pulling the right book onto the desk.
Start here
The model does not "know" what is in your database. Retrieval is how the right slice gets into the context, where the model can actually use it. Everything downstream is capped by retrieval quality: if the right document is not fetched, no amount of reasoning recovers it.
RAG: retrieve relevant context, then generate from it
Toy corpus with keyword-overlap retrieval (real systems embed and search by vector similarity) — the loop shape is identical: query → retrieve top-k → stuff into prompt → generate with citations. Toggle rerank on: a second, query-aware scorer re-orders candidates — chunk 6 (about fees, no keyword overlap) jumps into top-k. Rerank scores here are fixed values standing in for a cross-encoder.
RAG for agents
The loop is: embed the query, search the store for nearby items, augment the prompt with the top hits, and generate against them. For an agent the query is often not the user's words but a rephrasing the agent chose ("duplicate charge refund policy") — so retrieval quality depends on how well the agent queries, not just on the index.
Retrieval as memory
- Semantic memory is a document or vector store of facts and policies; retrieval is nearest-neighbour search over embeddings.
- Episodic memory is a log of past events and outcomes; retrieval is by recency, similarity, or both.
- Procedural memory is often not retrieved at all — it is the tool list, present in every prompt.
Citations make it checkable
When retrieved text carries a source, the agent can cite it and a human can verify it. That turns a fluent answer into an auditable one — and it is the same provenance idea that the safety chapter relies on to resist injection.
Careful
Retrieval is not a truth machine. A confident hit can be outdated, irrelevant, or wrong, and the model will happily use it. Chunk size, embedding quality, and ranking all silently decide what the agent sees. Measure retrieval separately from generation — if the right document is not in the top-k, the agent's answer was never going to be right.
Check yourself
Eduspheria wiki · Agentic AI, Memory & context
0 / 4 answered
Next: memory that survives the session — long-term stores.