AgentenCode · Field guide

Agentic RAG: How AI agents retrieve, verify and use knowledge

Agentic RAG explained: hybrid search, source verification, permissions, bounded retrieval and evaluation with a worked example.

AgentenCode Editorial · November 26, 2026

Agentic RAG: How AI agents retrieve, verify and use knowledge
Original editorial illustration by AgentenCode.

Agentic RAG is an architecture in which an AI agent controls access to external knowledge according to the requirements of a task. Unlike a simple retrieval-augmented generation pipeline, it can decompose questions, select different search paths, assess intermediate results and perform focused follow-up retrieval when evidence is insufficient. This approach is particularly interesting for complex professional questions, enterprise knowledge systems and research agents. It is not automatically more accurate or less expensive than simple search. Quality depends on verifiable sources, suitable retrieval methods, controlled execution and explicit stopping rules.

Key takeaways

RAG connects a language model to externally supplied information. Agentic RAG adds a controllable research process. An agent may decide whether to search a database or a document first, refine a term or determine whether the available evidence is sufficient. These additional decisions can improve multi-part research tasks while increasing costs, latency and the number of potential failure points. An architecture should therefore start with the simplest adequate retrieval strategy and add autonomy only where it provides demonstrable benefits.

1. What retrieval-augmented generation actually does

A language model has knowledge from its training and information supplied in its current context. It does not automatically have access to current internal policies, confidential contracts or recently published research. Retrieval-augmented generation, or RAG, supplements the model context with material from an external collection. The foundational paper by Lewis et al. (2020) investigates the combination of parametric model knowledge with externally retrievable information for knowledge-intensive tasks.

In a typical modern RAG system, documents are divided into passages and stored in a search index with metadata. A user's question initiates retrieval. Selected passages are supplied alongside the task in the model context, and the generated response can refer to these passages. Unlike retraining, adding documents to an index does not require changing model weights. However, external documents are not necessarily correct, current or accessible to every user.

A crucial distinction is that retrieval produces candidates, while generation formulates an answer. Finding a good passage does not guarantee that the model interprets it correctly. Conversely, convincing prose does not establish that the answer is supported by evidence. Both stages need independent evaluation. The system should be able to explain which reference was available and whether it actually supports the particular claim.

2. Classical RAG, hybrid search and agentic RAG

Comparison of fixed and agent-controlled retrieval flows
Comparison of fixed and agent-controlled retrieval flows · AgentenCode

Simple RAG follows a predefined sequence: question, search, context and answer. Hybrid retrieval combines techniques such as lexical matching and semantic similarity. This is a retrieval method, not automatically an agent. The distinctive agentic component is control: an application or agent may change the research plan, issue multiple queries and decide whether additional evidence is needed.

ArchitectureUseful forPrincipal limitation
Keyword searchProduct names, exact terms, document titlesSynonyms and complex intent may be difficult to match
Vector searchSemantically related passagesSimilarity is not truth or authorization
Hybrid RAGQuestions combining technical terms and semantic meaningRanking and source quality need calibration
Agentic RAGMulti-part questions, source comparison and follow-up retrievalMore calls, latency and harder-to-audit behavior

Microsoft's agentic retrieval documentation describes a knowledge-base approach that coordinates multiple queries and sources. It is an example of a managed retrieval architecture, not the only possible implementation. An agentic RAG system can also use custom retrieval tools and a defined state machine. Not every multi-step pipeline needs an unconstrained planning model. A deterministic workflow can perform known search stages and delegate only ambiguous retrieval choices to a model.

3. The knowledge architecture: Indexes, metadata and permissions

Before agents can research, their sources must be made searchable in a useful way. A document pipeline extracts text, preserves headings, table relationships and page references, records document versions and divides content into retrievable units. The appropriate chunk size depends on document type and task. Very short passages may separate important definitions from their context; large passages may add irrelevant information to the response. Overlapping chunks help near passage boundaries but increase indexing and storage requirements.

Each passage should have a stable document identifier, version, source, validity date and access information. For a contract, for example, the precise version matters more than semantic similarity alone. An outdated but closely worded policy must not automatically substitute for a current policy. In multilingual collections, establish explicit relationships between translations without treating independently maintained versions as identical.

Knowledge pipeline with permission filtering and source versions
Knowledge pipeline with permission filtering and source versions · AgentenCode

Authorization is part of the retrieval architecture. A search service should return only candidates accessible to the identity making the request. A subsequent prompt telling the model not to disclose information is not equivalent to access enforcement. Cached responses must also be bound to the appropriate permission boundaries. When documents are deleted or access is revoked, the retrieval pipeline must reflect that change reliably; otherwise it creates a stale secondary access path. Similar concerns apply to exported search results and retained agent memory.

4. Worked example: Interpreting an enterprise policy

Imagine an employee asking: “May I process customer data using an external AI agent if the provider does not use it for training?” This is a multi-part question. A simple search might find only a vendor statement about training and infer permission too broadly. Internal approvals, data categories, processing context and contractual conditions are also relevant.

A bounded agentic retrieval process decomposes the request into three questions: Which internal policy applies? Which types of data are permitted? Which documented provider terms are relevant? The agent receives read access to authorized policies and an approved collection of public provider documentation. It retrieves each set of documents separately, checks their validity and compares the statements. If no current policy for customer data is found, the agent reports the evidence gap rather than deriving permission from the absence of a prohibition.

A response might say: “The statement about training answers only one part of your question. Permission to process customer data cannot be established from the documents retrieved. Please consult the identified policy and the responsible privacy team.” This is not a legal decision; it is an accountable statement about the available documentation. The agent must not transfer data or issue an approval. The scenario demonstrates why acknowledging insufficient evidence is often more useful than producing a fluent but unsupported answer.

5. Retrieval quality and source verification

A useful retrieval output provides not just text but traceable source references. A reference should ideally identify a specific document and section; page numbers, timestamps or stable anchors improve verification. Relevance scores are useful for sorting candidates, but they must not be interpreted as probabilities of truth. A highly relevant source may still be outdated, incorrect or one-sided. The most recent document also may not be the authoritative one if it is a draft or applies to a different jurisdiction or product version.

In agentic retrieval, verification should be a distinct step. An agent may discover conflicting statements and search for a newer version. Resolving a contradiction should depend on validity, responsible authority and documented provenance. If these criteria do not resolve it, the uncertainty should remain visible. A third source does not automatically create a reliable majority vote.

A practical rule is to attach a supporting reference to every material verifiable claim in the answer, ensuring the referenced passage actually supports that claim. Where an answer depends on assumptions, state them explicitly. When the collection has no evidence, distinguish “not established” from “false.” Human review is appropriate for sensitive use cases. This approach also makes it easier to audit why a response changed after a source update.

6. Security risks and boundaries

Retrieved material may contain malicious instructions. A webpage or document can attempt to induce an AI agent to abandon its original task or disclose sensitive information. This is indirect prompt injection. OWASP's prompt injection reference describes several such entry points. Manipulated embeddings, inappropriate retrieval candidates and authorization violations are additional concerns; the OWASP reference on vector and embedding weaknesses discusses this distinct category of risk.

The retrieval process should treat external text as data. A command read from a document does not grant authorization to invoke a tool. Where an application has write capabilities as well as search tools, an independent control layer must prevent retrieved instructions from triggering unauthorized effects. For many question-answering applications, a read-only tool set is sufficient. Other measures include source approval, logging, permission filtering and controlled ingestion of new documents.

Protection depends on the threat model. Public indexes can contain false information, while internal indexes may disclose confidential material. A model-level filter cannot solve these issues completely. The architecture must remain safe even if an agent mistakenly interprets an untrusted source as an instruction. Review ingestion provenance and permission boundaries separately from model output quality. Do not send sensitive records to an external search system merely because the system returns relevant results.

7. Costs and bounded research

Research budget and stopping decisions
Research budget and stopping decisions · AgentenCode

Agentic RAG may incur additional costs from multiple searches, model decisions and ranking stages. A realistic budget includes ingestion, storage, search calls and external sources as well as generation. An agent that repeatedly reformulates every question can consume more resources than a simple retrieval pipeline despite producing a relatively small answer. The number of retrieval steps is therefore a technical control rather than simply a stylistic preference.

An illustrative policy might allow at most three search rounds, five candidates per round and a bounded context size. These are example limits, not universally recommended values. If adequate evidence remains unavailable, research ends with a clearly stated gap. External paid search tools may require separate approval. Caching can reduce repeated searches but must respect source validity and authorization. A retry mechanism must also distinguish a temporary service error from an empty result so that it does not run indefinitely.

MeasureWhat it evaluatesCommon mistake
Recall@kWhether relevant references appear among the first k resultsEvaluating only the retrieved items
Citation precisionWhether references support the actual claimsCounting every URL as evidence
Authorization testsWhether forbidden documents remain inaccessibleTesting only normal user permissions
Answer completenessWhether each subquestion is addressed correctlyConfusing eloquence with completeness
Cost per verified answerRetrieval and generation including failed attemptsCounting output tokens alone

8. Practical adoption

Start with a small, versioned document collection and a fixed set of evaluation questions. For each question, identify expected sources, permitted access, required subanswers and cases where the system should abstain. Implement simple search or hybrid RAG first. Add agentic control only when observed failures show that additional retrieval decisions would help. Compare both variants with the same test cases, including ambiguous questions, inaccessible documents and intentionally contradictory material. Record the results without treating a small internal evaluation as a universal benchmark.

In operation, retrieval should remain traceable: queries, selected references, model version, latency and stopping reason are useful diagnostic information. Sensitive data should not be logged indiscriminately. A later model or index change may alter results, requiring renewed evaluation. A separate approval for new data sources prevents a small knowledge base from becoming an uncontrolled web-access system. Our knowledge hub contains related references on context engineering, security, agent evaluation and costs.

Frequently asked questions

Is agentic RAG always better than ordinary RAG? No. A fixed process is often faster, cheaper and easier to verify for straightforward questions. Agentic control is useful when the task genuinely requires multiple retrieval decisions.

Does agentic RAG require a vector database? No. Keyword search, SQL, structured APIs or combinations can also be suitable retrieval tools. The control logic is the defining distinction.

Can an agent using RAG hallucinate? Yes. It may select incorrect sources, misinterpret content or add unsupported claims. Source-based verification remains necessary.

Can private documents be included? Only if processing, access, storage and retention are governed appropriately. The retrieval request must enforce the individual user's rights.

How is RAG different from memory? RAG retrieves external information for a current task. Memory describes stored state or experience across interactions and may itself use retrieval.

How many search steps should be allowed? This depends on the questions, costs and risks. An explicit upper bound and stopping rule for insufficient evidence matter more than a universal number.

Conclusion

Agentic RAG can improve complex research tasks by adapting retrieval to intermediate findings. Its value depends on whether sources, permissions, versions and resource consumption remain under control. A good system knows not only where to search, but when the available evidence is insufficient. This capability is at least as important for reliable knowledge work as having access to a larger number of search tools. Begin with a testable baseline, add complexity selectively and treat source verification as an independent requirement.

Sources and further reading

Sources checked 26 November 2026. Architecture examples and budgets are editorial proposals, not measured results.

NEWSLETTER · FREE · GERMAN EDITION

More signal. Less AI noise.

Our source-backed German-language digest of major AI developments, agent updates and knowledge articles. The weekly edition is being prepared.

Double opt-in: Subscription starts only after email confirmation. Your details are sent to Brevo when you submit.