Wiki
Core11 min read

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

#2
kw 2.00 · rr 0.95Tuition fees are ₹48,000 per year for grades 6–8, with a 10% sibling discount.
#1
kw 0.00 · rr 0.35Riverdale School was founded in 1998 by educator Mira Kapoor.
#3
kw 0.00 · rr 0.12The robotics club meets on Tuesdays after school in Lab 2.
#4
kw 0.00 · rr 0.18Bus routes cover 12 neighborhoods, with pickup at 7:20 AM.
#5
kw 0.00 · rr 0.08The annual sports day is held in December on the main field.
#6
kw 0.00 · rr 0.88Payments are handled at the accounts office; concessions apply yearly.
Answer: Tuition fees are ₹48,000 per year for grades 6–8 (10% sibling discount). [source: chunk 2]

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

  1. 1In RAG, what is the first step for a query?
    Multiple choice
  2. 2What does RAG stand for?
    Short answer
  3. 3Procedural memory is usually retrieved by similarity search like semantic memory.
    True / false
  4. 4Why does the lesson say to measure retrieval separately from generation?
    Multiple choice

Next: memory that survives the session — long-term stores.