Grounding Agents in Your Own Data (RAG)

The main benefit of RAG on the agent path — feeding your datastore into context when it lives outside model weights — and the second advantage: search by meaning with embeddings.

iMORPHr · · 5 min read
Grounding Agents in Your Own Data (RAG)

Part 3 of 4 · ← Previous: context engineering · Next: MCP →

Context engineering is about everything the model sees. One large piece of that picture is knowledge that does not live in the model weights and is not already in the chat: your docs, records, messages, and product data.

RAG — retrieval-augmented generation — is how that knowledge enters context when it is needed. This post is not a pipeline tutorial. It is the experience map that made RAG feel necessary on our agent path: first ground the agent in your datastore; then, when the question is about meaning, retrieve by semantics rather than keywords.


The main benefit: knowledge outside the weights

A model’s training data is not your CRM, your mailbox, or your company notes. Those live in your systems. If an agent only has the weights plus the current chat, it will guess, refuse, or sound confident about facts it does not have.

The primary reason we care about RAG is simple: feed information from the user datastore into the model’s context — records and knowledge that sit outside what the model already “knows.”

That is the grounding move. Without it, agents that talk about your customers, communications, or signals are performing over a hole.

You could try to paste everything into the window. That collides with everything in the previous post: rot, pollution, cost, and confusion. Retrieval says: fetch the relevant pieces from your store for this question, then let the model use them. From the agent side, RAG is a context move — not a separate religion.

If you read my earlier LLM vocabulary notes, the same mindset applies: care about whether you retrieved the right material, not only whether the final answer “sounds good.” I will not rehash metrics here. The habit is enough — do not tune on vibes alone.


Two flavours: when retrieval happens

Same grounding goal — your datastore into context. Two common ways it shows up on the agent path:

1. Classic RAG (retrieve up front). The application retrieves relevant pieces from your store before (or as it builds) the model call, then sends the user query together with that grounding context. The path is mostly fixed: query → retrieve → generate. Simple questions that map to one search against one store often fit this shape. It is predictable, and usually cheaper and faster than a multi-step loop.

2. Agentic RAG (retrieve when the model asks). Retrieval is exposed as a tool. The model decides whether it needs your data, calls the retrieval tool, reads what came back, and may call again — or skip retrieval entirely when the question does not need the datastore. That is the same agent loop from post 1, pointed at a knowledge base: the model proposes a fetch; your backend runs it; results re-enter context.

What agentic RAG often adds beyond “fetch once on demand” is judgment in the loop: reformulate the search, try another source, pull communications then enrichment, or stop when evidence is enough. That helps multi-step or ambiguous questions. It also costs more latency and tokens — so it is not automatically “better” than classic RAG for every ask.

For our CRM direction, both flavours matter conceptually: sometimes you want a straight grounded answer from known stores; sometimes an agent should decide when to search communications or enrichment data as the task unfolds.


Second advantage: search by meaning

Once you are retrieving from your own data, how you find the right pieces matters.

Keyword and exact-match search work when the user asks for a known field or phrase. They fall short in ordinary product language — and that is where embeddings and semantic retrieval earn their place.

Communications. Someone asks: list communications that had a positive response from clients. There is no reliable single keyword for “positive.” Tone and outcome live in phrasing, context, and implication. Searching for “happy” or “thanks” is a brittle proxy for the question they actually asked.

Companies. Someone asks for companies with good financial health, or with an insight or signal that makes them a possible customer. Again, that is not WHERE status = 'lead'. It is judgment over heterogeneous evidence — filings, news, notes, patterns — expressed in natural language.

Those are the moments meaning search stopped being an abstract course topic for me. Agents that work over CRM-shaped work need to ground answers in our datastore and find the right slices by meaning. We are building that for two stores of our own data: the communications captured in our CRM (email, phone, messages), and the company enrichment data we gather as signals about accounts. The requirement already shapes how we think about the product, even while the implementation is still underway.


What I want another engineer to take away

  • First: RAG exists to bring your data into context — knowledge outside model weights. A bigger window or a “smarter” model does not replace a real datastore.
  • Second: when users ask for meaning, plan for semantic retrieval (embeddings), not only keywords.
  • Know the two flavours: classic RAG (retrieve up front with the query) vs agentic RAG (model fetches through tools as needed) — same grounding idea, different control.
  • Treat all of that as context engineering: what gets fetched from your systems, for which turn, in what form.

What this post is not: chunking recipes, embedding bake-offs, or a how-to for wiring a vector store. Those belong in implementation docs when you are ready to build. Here the point is the order of the lesson — ground in your data first; choose how retrieval is controlled; use meaning search when the question demands it.


What’s next

Retrieval and tools still have to live somewhere agents can reach them. If every agent harness needs custom glue to your system, you encode someone else’s workflow inside your app — or you rebuild integrations per harness.

  • Post 4: MCP — same system, operable from different agent harnesses.

Series

  1. What “Agent” Meant After I Stopped Guessing
  2. Everything the Model Sees (Context Engineering)
  3. Grounding Agents in Your Own Data (RAG) (this post)
  4. Same System, Different Agent Harnesses (MCP)

Earlier series — LLM trilogy

  1. A Practical LLM Map for Full-Stack Engineers
  2. LLM Vocabulary for Engineers: Embeddings, Evals, Quantization, and LoRA
  3. Tools Make the LLM Useful: Lessons from an ERPNext Chatbot Experiment