When RAG isn't enough: Why your agents need governed context to run a workflow

Written by
Last updated on:
November 25, 2026

Retrieval-augmented generation helps agents read your documents. To run a workflow, they also need numbers they can trust, and that takes a governed context layer.

Picture a planner at a mid-sized distributor. One warehouse is running low on a part, and another has more than it needs. Moving stock between sites means checking current inventory and demand, reading the transfer policy, drafting the customs paperwork, getting a sign-off, and entering the move in the ERP. The work crosses planning and logistics, and finance gets pulled in too. For a person, it takes a good part of an afternoon.

Now imagine an AI agent that does most of that work. It recommends what to move, drafts the paperwork, waits for the planner to approve, and then makes the entry in the ERP.

Whether that agent can be trusted depends on more than a good language model. The first thing it needs is numbers it can rely on.

Two colleagues with glasses reviewing a tablet and a clipboard of documents at a desk with computer monitors, agreeing on the metric definitions behind a semantic layer

How does retrieval augmented generation (RAG) work?

Large language models only know what was in their training data, so on their own they can't answer questions about your proprietary data or anything that changed after training. Retrieval augmented generation (RAG) fixes that by using information retrieval to give the model relevant information at the moment the user asks, so it can produce context aware responses.

A typical RAG pipeline has a few building blocks. The first step is embedding generation: an embedding model turns your text documents into vector embeddings, which are numerical representations of their semantic meaning. These dense vectors go into a vector database alongside the source data. When a user asks a question, the same embedding model converts the user's query into a vector, and a vector similarity search looks for similar vectors to find documents that match. It returns the most relevant chunks: the text whose vectors sit closest to the query's. Those retrieved documents are added to the prompt, and the model writes a response based on the retrieved context.

This is semantic search, and it's good at matching the user's intent even when the wording differs. Many RAG systems also use hybrid search, which combines similarity search with keyword search for improved relevance, and metadata filtering to narrow the knowledge base before searching. The approach works with open source models as well as hosted ones. The same techniques power recommendation systems and many AI assistant tools.

For questions that a passage of text can answer, this works well, and it's often cheaper and easier to keep up to date than fine-tuning a model. It's one of the main building blocks of generative AI applications today. In production systems, though, the quality of relevant results only goes so far. The trade-offs show up when the question needs a calculation rather than a passage, and the model can't answer correctly from text alone.

Why do AI agents need more than RAG?

Ask an AI agent to summarize your transfer policy and it does a good job, because RAG can retrieve relevant documents and answer questions from them. Ask it how many units of a part are on hand at each site, and what demand looks like next month, and the answers are less dependable. The numbers often can't be traced back to a credible source, and that erodes user trust quickly.

The difference is in the questions. The first one is about reading. The second one is about calculating, and that's where the limits of standard RAG (retrieval augmented generation) start to show.

This is where a governed context layer comes in. It works alongside RAG rather than replacing it. The context layer handles the structured, numbers-heavy side of your business, and RAG keeps doing what it's good at.

Where does standard RAG fall short?

Math and aggregation

RAG finds semantically similar text chunks, the ones whose vectors look like your question. Summing, averaging, or working out year-over-year growth across millions of rows is a job for a database engine. Asking a language model to do it from retrieved text is like asking a well-read intern to total a year of sales by flipping through a stack of PDFs. You'll get an answer. You just won't want to put it in the board deck.

Joins and business logic

A database schema doesn't explain itself. "Active customer" might mean a join across three specific tables, with test accounts (status = 'test') filtered out. RAG has no way to know that. Somebody has to write the rule down once, in a form a machine can follow every time.

Conflicting definitions

Say you have five reports and a few SQL scripts that each define Net Revenue a little differently. The model will pick one, with great confidence and no real basis. A governed layer holds a single approved definition that accounts for those variations, so there's nothing to guess.

Access control

Vector indexes usually control access at the document or index level, so every user who can reach a document can find its retrieved information. A regional manager who should only see West Coast sales needs row-level and column-level rules applied at the moment the query runs. A vector index without those rules is a friendly librarian who was never told which shelves are locked.

Fresh data

Transactional data, like inventory counts, changes all day. Chunking it and re-embedding it over and over adds delay, and the answers go stale. A context layer turns the natural language question into SQL and runs database queries against current data instead, which gives the agent real time data retrieval from your external databases.

RAG vs semantic layer: how a governed context layer compares

Standard RAG vs. a governed context layer: best use, how it works, accuracy on math and KPIs, business logic, and access control
ComparisonStandard RAG (vector search)Governed context layer (semantic layer plus metadata)
Best forUnstructured content: PDFs, docs, transcripts, wikisStructured and semi-structured data: tables, views, metrics
How it worksFinds similar text, then generates an answerRoutes by metadata, then generates SQL the database runs
Accuracy on math and KPIsLow, because calculations can be made upHigh, because the database engine does the calculating
Business logicImplicit, buried in textExplicit, written into semantic views and metric definitions
Access controlCoarse, often by document or indexFine-grained: role-based access, row and column masking

How RAG and a governed context layer work together

In a modern enterprise setup, RAG becomes one tool inside the context layer. Back to the transfer example, here's how the agent builds its recommendation:

  1. The governed context layer runs a verified SQL query and returns the exact on-hand inventory and forecast demand for each site.
  2. RAG searches the transfer policy and notes from past exceptions, such as earlier moves that were held up at customs, to add context to the numbers.

The numbers come from the database. The rules and history come from the documents. This approach is often called context engineering. It goes beyond prompt engineering by deciding which source each part of the answer comes from, and it's a sturdier way to build an AI system than asking one retrieval step to do both jobs.

What else does an agent need to run a workflow?

Trusted information gets an agent to a good recommendation. Running the workflow takes four things in all. Governed context is the first. These are the other three:

  • Actions in your systems of record. The agent has to write to your ERP or ticketing system, not only answer questions. That takes scoped credentials and a record of every change it makes.
  • Human gates, with autonomy that's earned. At first the agent recommends and a person approves. As its accuracy is proven, it gets more room. You wouldn't give a new hire write access to the ERP on day one with nobody checking, and an agent deserves the same gradual start.
  • Evals and an answer key. A set of real questions and past decisions with known-good outcomes, so you can see the agent getting it right before it acts. Useful measures to track include planner time per transfer and how often people override the agent.

For more on building agents that act inside your systems, see our Agentic Workflow Implementation services.

Which tools can you use for the grounding step?

Open source

  • Cube Core. An open-source semantic layer. Its backend is Apache 2.0 licensed and its client libraries are MIT licensed. It serves the same metric definitions to BI tools, applications, and AI agents through SQL, REST, and GraphQL APIs. Cube also sells a paid platform built on top of it.
  • dbt MetricFlow. The engine behind the dbt Semantic Layer. dbt Labs moved it to the Apache 2.0 license on October 14, 2025, starting with version 0.209.0. You define metrics in YAML next to your dbt models, and it compiles them to SQL. Running MetricFlow yourself is free. Serving those metrics to BI tools and agents through the hosted dbt Semantic Layer needs a paid dbt plan, Starter or above.

Paid and platform-native

  • Snowflake semantic views with Cortex Analyst. Semantic views are schema-level objects that store your metrics and dimensions, plus the relationships between them. Cortex Analyst reads them to turn plain-English questions into SQL. Because they're ordinary Snowflake objects, access is managed with Snowflake privileges.
  • Databricks Unity Catalog metric views with Genie. Metric views are governed in Unity Catalog, and Genie can query them to anchor its answers. Zalando has described defining its metrics in YAML files in a central repository, with every change reviewed through a pull request, which is a good example of treating definitions like real code.

The tooling here is evolving rapidly. One more effort to watch is the Open Semantic Interchange, which includes dbt Labs and Snowflake among its partners. Its goal is to fix inconsistent metric definitions by letting them move between tools, so you aren't locked into one vendor's format.

What a governed context layer doesn't solve

A governed layer is only as good as the definitions inside it. Somebody still has to decide what Net Revenue means, and finance and sales may not agree on the first try. That's a people problem before it's a tooling problem, and it takes real modeling work and upkeep.

A trusted number also isn't an automated workflow. Actions in your systems, plus the approvals and evals around them, are real work too, and the first project will teach you things no article can.

It isn't for every project, either. If your question set is a few hundred documents and nobody needs accurate numbers, a plain RAG system is simpler and does the job. A context layer also won't fix edge cases in your source data on its own. And a context layer can only enforce the permissions you give it. If access rules in the source systems are a mess, the layer will pass the mess along.

Have a workflow in mind?

If you have one workflow that crosses teams and takes people real time, we'd be glad to talk it through with you: what an agent could do, and where a person should stay in the loop. Our Agentic Workflow Implementation team builds agents that work inside your systems of record, and our forward-deployed engineers can work alongside your team to set up the context layer, approvals, and evals.

Learn more

Frequently asked questions

Retrieval augmented generation (RAG) retrieves external knowledge in response to users' questions, using vector search to find text that's similar before generating an answer, which works well for documents and large knowledge bases. A semantic layer stores approved metric definitions, maps business terms to the underlying data structures to keep definitions consistent, and turns questions into SQL that the database runs, which works well for numbers and KPIs.

A governed context layer combines a semantic layer with metadata and access rules. It gives AI agents a single approved definition for each metric, applies permissions when the query runs, and pulls current data from the database.

No. RAG still handles unstructured content like policies, transcripts, and past notes; RAG lLies in pulling in company-specific external content, while the context layer governs metrics and permissions. The context layer handles structured data and calculations, and the agent uses both.

Context engineering is the practice of giving an AI agent the right information from the right source for each part of a task, such as numbers from a database and rules from documents, instead of relying on a single retrieval step.

If your use case is answering questions from a few hundred documents and nobody needs precise numbers, plain RAG is simpler and usually does the job.