Agent Framework RAG for Agents: Giving Your Agent the Right Context A developer building on the Microsoft Agent Framework describes how to connect agents to private knowledge using RAG (Retrieval-Augmented Generation). The approach exposes retrieval as a controlled tool, SearchKnowledgeAsync, rather than giving the agent direct access to databases or all documents. The agent fetches relevant context only when needed, keeping the retrieval layer separate from the agent runtime. This is Part 13 of my series on the Microsoft Agent Framework. You can read the original post over on lukaswalter.dev . In the previous article https://www.lukaswalter.dev/posts/agentframework 1 12/ , we looked at workflows. Workflows make sense when the process itself needs structure: state, checkpoints, events, human approvals, and resumable execution. This post is the bridge from Agent Framework into RAG. I plan on doing a full RAG deep dive sometime later. The practical question for now is smaller: How do I connect an Agent Framework agent to private application knowledge without stuffing every document into the prompt? For agents, RAG is less about adding more text and more about giving the agent a controlled retrieval path. The agent should fetch the right context at the point where it needs it. Your company documents, product catalog, tickets, rules, policies, runbooks, and internal knowledge base live outside the model. The model has generic knowledge. Your application has private knowledge. Treat those as separate systems. You can paste some private data into the prompt, and for a demo that may be enough. But this falls apart quickly: The last point is easy to underestimate. A larger context window lets you send more text. It does not decide which text is correct, current, relevant, or permitted. Do not give the agent all knowledge. Give it the right context at the moment it needs it. Retrieval owns that job. The basic RAG loop is small: php user question - retrieve relevant chunks - pass chunks to the agent - agent answers using that context For documents, the longer pipeline usually looks like this: php documents - chunks - embeddings - vector store - search - retrieved context - agent response Documents are split into smaller chunks. Those chunks are embedded into vectors. The vectors and source metadata are stored. When a user asks a question, the question is embedded too. The search layer finds nearby chunks and returns only those chunks to the agent. Stop there for now. There are some hard parts here: chunk boundaries, embedding model choice, hybrid search, reranking, freshness, access control, observability, and evals. They are just not the point yet. For now, keep the boundary clear: RAG is the retrieval layer around the agent. The agent is not the retrieval layer. Microsoft Agent Framework gives you the agent runtime. It does not give you a finished ingestion pipeline, chunking strategy, embedding setup, vector store, ranking model, permission model, freshness process, or retrieval eval suite. Agent Framework helps you decide how the agent receives and uses context: The retrieval system still belongs to your application architecture. It might use Azure AI Search, PostgreSQL with pgvector https://www.lukaswalter.dev/posts/rag-efcore-pgvector/ , SQL Server vector search, Cosmos DB, Qdrant, Redis, a normal search index, or an internal HTTP API. The agent does not need to care. The agent needs a focused capability. Not direct database access. For many agent apps, I would start by exposing retrieval as a tool. The tool is narrow: SearchKnowledgeAsync string query, string? category, int limit The agent can call it when the answer depends on private knowledge. Your application decides what the tool is allowed to search. This matches the tool-design rule from earlier in the series: Tools should expose controlled capabilities, not raw infrastructure. A small version looks like this: using System.ComponentModel; using Microsoft.Agents.AI; using Microsoft.Extensions.AI; using Microsoft.Extensions.DependencyInjection; public sealed record KnowledgeSearchResult string Title, string Source, string Snippet, double Score ; public interface IKnowledgeSearch { Task