---
title: "Retrieval-augmented generation pattern for AI agents | Agentic Pattern Language"
description: "One retrieval step before the call: add passages relevant to the query to the prompt. Sourced from Lewis et al., Xu et al., and Anthropic."
url: https://agenticpatternlanguage.com/patterns/retrieval-augmented-generation/
---

18 [One call](https://agenticpatternlanguage.com/#one-call)

# Retrieval-augmented generation

One retrieval step before the call: add passages relevant to the query to the prompt.

Also called RAG

Lewis et al., Xu et al., Anthropic, Amazon Web Services, Microsoft

[How to read this](https://agenticpatternlanguage.com/notation/)

## Builds on

* [Contextual retrieval](https://agenticpatternlanguage.com/patterns/contextual-retrieval/)
* [Reranking](https://agenticpatternlanguage.com/patterns/reranking/)
* [Query rewriting](https://agenticpatternlanguage.com/patterns/query-rewriting/)

## Alternatives

* [Just-in-time context retrieval](https://agenticpatternlanguage.com/patterns/just-in-time-context-retrieval/)

## The problem

The model needs knowledge it was not trained on, or that is newer than its training data.

> For an AI model to be useful in specific contexts, it often needs access to background knowledge.

Anthropic [Contextual retrieval in AI systems](https://www.anthropic.com/engineering/contextual-retrieval) Sep 19, 2024

> LLM training data is static and introduces a cut-off date on the knowledge it has.

Amazon Web Services [What is RAG? - Retrieval-Augmented Generation AI Explained](https://aws.amazon.com/what-is/retrieval-augmented-generation/)

## Therefore

> RAG is a method that retrieves relevant information from a knowledge base and appends it to the user's prompt, significantly enhancing the model's response.

Anthropic [Contextual retrieval in AI systems](https://www.anthropic.com/engineering/contextual-retrieval) Sep 19, 2024

> Retrieval-augmented generation (RAG) is a pattern that extends LLM capabilities by grounding responses in your proprietary content.

Microsoft [Retrieval-augmented generation (RAG) in Azure AI Search](https://learn.microsoft.com/en-us/azure/search/retrieval-augmented-generation-overview)

> We explore RAG models, which use the input sequence x to retrieve text documents z and use them as additional context when generating the target sequence y

Lewis et al. [Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks](https://arxiv.org/abs/2005.11401)

## In use

Claude Projects

> As you add more files and information to your projects, Claude automatically switches to a faster mode (powered by RAG) that keeps response times quick while maintaining quality responses.

Anthropic [Retrieval augmented generation (RAG) for projects](https://support.claude.com/en/articles/11473015-retrieval-augmented-generation-rag-for-projects)

LinkedIn customer service

> Our method has been deployed within LinkedIn’s customer service team for approximately six months and has reduced the median per-issue resolution time by 28.6%.

Xu et al. [Retrieval-Augmented Generation with Knowledge Graphs for Customer Service Question Answering](https://arxiv.org/abs/2404.17723)

## Where it breaks

Encoding text for retrieval strips its context, so retrieval can miss the passage that answers.

> The problem is that traditional RAG solutions remove context when encoding information, which often results in the system failing to retrieve the relevant information from the knowledge base.

Anthropic [Contextual retrieval in AI systems](https://www.anthropic.com/engineering/contextual-retrieval) Sep 19, 2024

## Sources

1. [Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks](https://arxiv.org/abs/2005.11401) Patrick Lewis, Ethan Perez, Aleksandra Piktus, Fabio Petroni, Vladimir Karpukhin, Naman Goyal, Heinrich Küttler, Mike Lewis, Wen-tau Yih, Tim Rocktäschel, Sebastian Riedel, Douwe Kiela, Lewis et al.
2. [Retrieval-Augmented Generation with Knowledge Graphs for Customer Service Question Answering](https://arxiv.org/abs/2404.17723) Zhentao Xu, Mark Jerome Cruz, Matthew Guevara, Tie Wang, Manasi Deshpande, Xiaofeng Wang, Zheng Li, Xu et al.
3. [Contextual retrieval in AI systems](https://www.anthropic.com/engineering/contextual-retrieval) Anthropic, Sep 19, 2024
4. [What is RAG? - Retrieval-Augmented Generation AI Explained](https://aws.amazon.com/what-is/retrieval-augmented-generation/) Amazon Web Services
5. [Retrieval-augmented generation (RAG) in Azure AI Search](https://learn.microsoft.com/en-us/azure/search/retrieval-augmented-generation-overview) Microsoft
6. [Retrieval augmented generation (RAG) for projects](https://support.claude.com/en/articles/11473015-retrieval-augmented-generation-rag-for-projects) Anthropic

Added Nov 14, 2026
