Learn Agentic Patterns
CoursesInterviewSchoolVideosAI agent videosAI now
Learn Agentic Patterns

Learn agentic AI, then get interviewed on it. A free course, four job paths, a daily broken agent, and the interview.

learnagenticpatterns.com

Navigation

HomeThe courseThe interviewPatterns (developer track)PM trackBlogCareer GuideAboutSign Up

Connect

Cheat sheet (free PDF)Reskilling guideLinkedIn (Mousa Jawaheri)

© 2026 learnagenticpatterns.com

Privacy PolicyTerms of Service

Based on “Agentic Design Patterns” by Antonio Gullí

> All Patterns

[01]Prompt Chaining[02]Routing[03]Parallelization[04]Reflection[05]Tool Use[06]Planning[07]Multi-Agent Collaboration[08]Memory Management[09]Learning & Adaptation[10]State Management (MCP)[11]Goal Setting & Monitoring[12]Exception Handling & Recovery[13]Human-in-the-Loop[14]Knowledge Retrieval (RAG)[15]Inter-Agent Communication (A2A)[16]Resource-Aware Optimization[17]Reasoning Techniques[18]Guardrails & Safety[19]Evaluation & Monitoring[20]Prioritization[21]Exploration & Discovery[22]Boundary Translation
HomeCurriculumKnowledge Retrieval (RAG)
Pattern [14]

Knowledge Retrieval (RAG)

≈ Database Querying / Search Index Integration (Elasticsearch)

[14]

TL;DR

Retrieval-Augmented Generation (RAG) equips agents with the ability to query external knowledge bases (Vector DBs, Search Indices) to ground their answers in fact and access proprietary data.

SWE: Database Query / Search Index
Architecture Flow
agentgate
Query ProcessoragentDocument RetrieveragentRelevance RankergateAnswer Generatoragent

> Agentic Definition

Retrieval-Augmented Generation (RAG) equips agents with the ability to query external knowledge bases (Vector DBs, Search Indices) to ground their answers in fact and access proprietary data.

Before: SQL Query

SQL Query
1-- SQL Query
2SELECT answer FROM faq WHERE topic = 'pricing';

After: Agentic RAG

Agentic RAG
1# Semantic Retrieval
2docs = retriever.get_relevant_documents(
3 "What is the pricing model?"
4)
5
6# Augment Context
7prompt = f"Context: {docs}\nQuestion: What is the pricing model?"
8
9# Generate Answer
10response = llm.generate(prompt)

Traditional SWE

Database Query / Search Index

≈maps to

Agentic Pattern

Knowledge Retrieval (RAG)

≈How They're Similar

Fetching data from storage to populate a view or answer a request.

≠Key Divergence

RAG involves semantic search (vector embeddings) rather than keyword match. It creates a prompt context, not just a data object. The "Schema" is the semantic meaning of the data chunks.

> Production Considerations

01

You must evaluate the Retrieval (Did we get the right doc?) and the Generation (Did the LLM use the doc correctly?). This is known as "RAG Triad" evaluation.

02

Vector search + LLM generation is slower than a DB lookup. Latency optimization requires careful indexing and caching strategies.

💡

Key Takeaway

Adapt: "Data Access Layer" now implies Vector DBs and Embedding Models. You are optimizing for "Context Relevance," not just query performance.

BuildBuild a Document Q&A Agent. Create a system that answers questions by retrieving relevant documents from a knowledge base, ranking them, and generating a grounded answer.

Frequently Asked Questions

When should I use the Knowledge Retrieval (RAG) pattern?

Retrieval-Augmented Generation (RAG) equips agents with the ability to query external knowledge bases (Vector DBs, Search Indices) to ground their answers in fact and access proprietary data.

How does Knowledge Retrieval (RAG) relate to Database Querying / Search Index Integration (Elasticsearch)?

Fetching data from storage to populate a view or answer a request. However, there is a key divergence: RAG involves semantic search (vector embeddings) rather than keyword match. It creates a prompt context, not just a data object. The "Schema" is the semantic meaning of the data chunks.

What are the production trade-offs of Knowledge Retrieval (RAG)?

You must evaluate the Retrieval (Did we get the right doc?) and the Generation (Did the LLM use the doc correctly?). This is known as "RAG Triad" evaluation. Vector search + LLM generation is slower than a DB lookup. Latency optimization requires careful indexing and caching strategies.

Further Reading

Blog · 3 min read

AI This Week: Agent Reliability, Knowledge, and Prompting

This week, we look at new approaches to knowledge retrieval for coding agents, leveraging expert insights for better prompting, and critical research on agent reliability.

Next Pattern

[15] · Inter-Agent Communication (A2A)