# Agentic RAG: retrieval that the agent controls

> Classic RAG retrieves once and hopes for the best. Agentic RAG turns retrieval into a tool the agent plans, repeats and checks.

Diego Bianqui · 2026-10-18 · https://diegobianqui.com/concepts/agentic-rag

## What RAG is

Retrieval-augmented generation (RAG) gives a model access to knowledge it wasn't trained on — your policies, products, contracts, tickets — by retrieving relevant passages at query time and placing them in the context before the model answers. It reduces hallucination, keeps answers current without retraining, and makes it possible to cite sources.

1. Ingest: collect documents and keep them in sync with their sources.
2. Chunk: split them into passages that make sense on their own.
3. Index: embed the chunks for semantic search, and usually index keywords and metadata too.
4. Retrieve: find the passages most relevant to the query.
5. Augment: put the best passages into the model's context, labelled as source data.
6. Generate: answer from those passages, ideally with citations.

## Where classic RAG breaks

- One shot: a single retrieval with the user's raw question, even when the question is vague, compound or needs several steps.
- One source: everything goes to one vector index, even when the answer lives in a database, an API or a different document store.
- No self-check: irrelevant or contradictory passages go straight into the answer.
- No permissions: the index returns passages the user was never allowed to see.

## What makes RAG agentic

In agentic RAG, retrieval stops being a fixed pre-processing step and becomes a set of tools the agent decides how to use. The agent can rewrite or decompose the question, choose which source to search, look at what came back, judge whether it is enough, and search again — before it answers or acts.

**Classic RAG versus agentic RAG**

| Aspect | Classic RAG | Agentic RAG |
| --- | --- | --- |
| Query | The user's question as typed | Rewritten, expanded or split into sub-questions |
| Sources | One index | Routed across vector search, keyword search, SQL, APIs and documents |
| Iterations | One retrieval | As many as needed, within a budget |
| Quality check | None | The agent grades relevance and looks for gaps or conflicts |
| Output | An answer | An answer, a decision or an action — grounded and cited |

The flexibility has a price: more model calls, more latency and more ways to go wrong. Agentic RAG needs the same discipline as any agent — budgets, tracing and evaluation from the [harness](https://diegobianqui.com/concepts/harness-engineering) and [AgentOps](https://diegobianqui.com/concepts/agentops).

## Design decisions that matter most

- Chunking that respects structure: sections, tables and clauses, not arbitrary character counts.
- Hybrid retrieval: semantic search plus keyword search, so exact terms like product codes and clause numbers are found.
- Reranking: a second pass that orders candidates by real relevance before they reach the context.
- Metadata filters: date, product, region, document type — often more effective than a better embedding model.
- Permission-aware retrieval: filter by what the requesting user may see, at query time, not after generation.
- Citations: every claim traceable to a passage, so users and auditors can check it.
- Retrieval as tools: expose sources through clear tool definitions, for example via [MCP](https://diegobianqui.com/concepts/agent-protocols).

## Security: retrieved text is untrusted input

Anything a retriever returns can carry instructions: a poisoned wiki page, a malicious email, a manipulated document. Treat retrieved passages as data, never as instructions, and never let them trigger actions without validation. The OWASP Agentic Top 10 lists this as agent goal hijack (ASI01) and memory and context poisoning (ASI06) — see the [guide](https://diegobianqui.com/concepts/owasp-agentic-top-10). Leaking documents across permission boundaries is the other big RAG risk, and it is solved in the retrieval layer, not the prompt.

## Measure retrieval and generation separately

When a RAG answer is wrong, the cause is either retrieval (the right passage wasn't found) or generation (it was found but misused). Evaluate both: context precision and context recall for retrieval, faithfulness and response relevancy for the answer. Libraries such as RAGAS implement these metrics — see [evaluating agents and RAG](https://diegobianqui.com/concepts/llm-evals).

## Related guides

- [Evaluating AI agents and RAG: evals, metrics and RAGAS](https://diegobianqui.com/concepts/llm-evals): If you can't measure an agent, you can't improve it, release it safely or defend it in an audit. Evals are how you measure.
- [Context engineering: what the model sees, and when](https://diegobianqui.com/concepts/context-engineering): Most agent failures are context failures. Context engineering is the discipline of deciding what the model sees at every step.
- [AI agent protocols: MCP, A2A, AG-UI, A2UI, AP2 and UCP](https://diegobianqui.com/concepts/agent-protocols): Agents talk to people, to other agents, to tools and to markets. Each of those layers now has its own open protocols. Here is the map.

## Sources

- [Available metrics](https://docs.ragas.io/en/latest/concepts/metrics/available_metrics/), Ragas documentation
- [OWASP Top 10 for Agentic Applications for 2026](https://genai.owasp.org/resource/owasp-top-10-for-agentic-applications-for-2026/), OWASP GenAI Security Project
