How to build the perfect context layer for data agents
Why organizational context—not schema alone—lets data agents answer trusted business questions. Three pillars, governance, and a headless context layer.
2026-11-13
Done right, organisational context management enables magical AI data analysts.
Why build a context layer?
Ask an AI system a general question, and it can often produce an impressive answer. Ask it a question about your business—“Why did revenue decline last month?” or “Which customers are most likely to churn?”—and the challenge changes completely because the model does not automatically understand:
- What “revenue” and “customer” mean inside your company
- Which tables contain authoritative data
- How those tables should be joined
- Which business rules must always be applied
- Which historical queries have already been reviewed and trusted
- What the person asking the question is actually allowed to access
This is why connecting an AI agent directly to a database is rarely enough. You need to onboard the AI model into your company like you would onboard a human. You can achieve that with a context layer.
Who should own the context layer?
In our view, the context layer is a collaborative effort between data teams, data governance teams and business teams.
Each group holds knowledge the others don’t:
- Governance teams know what data is certified, which definitions are official, and what kind of permissions and ownership model the org demands.
- Data teams know the structure: tables, pipelines, relationships, and quirks.
- Business teams know what the numbers mean: why “active customer” is defined the way it is, which edge cases matter, and what a good answer looks like.
- Power users and analysts connect all three. Their reviewed queries and corrections become the organisational memory the agent learns from.
When one group owns everything, the context layer drifts, is often incomplete, and filled with conflicting or bad definitions. Successful organizations treat context like a product with several contributors, each owning their part. Each group can and should use agents to accelerate drafting context creation but should be responsible for the quality of their slice of the context layer.

How to design a great context layer?
The DB schema is a start but not enough
Many text-to-SQL systems start by giving a model the database schema, and there are many tricks you can apply to make it AI-friendly (format it as code or markdown, use a compact schema with tables only or an extended one with columns, include primary and foreign keys, etc.).
A schema is useful, of course, but it doesn’t give a human or an AI analyst the full picture. A schema might show a column called amount, but it does not explain whether that amount represents gross revenue, net revenue, tax-inclusive value, or something else entirely. A schema may show several date columns without explaining which one should be used for financial reporting. This creates a dangerous situation: a silent failure. The generated SQL can be syntactically correct while the answer is wrong from a business point of view. The context layer sits between the user’s question and the agent’s answer and helps close the gap between the database’s technical structure and the organization’s business meaning.
The three types of context that should go into the context layer

The first pillar is structural data context from the data and analytics teams
It provides the foundation on which others build.
Structural metadata context describes how data is organized:
- Available tables and columns
- Existing descriptions and documentation
- Data types
- Relationships (primary and foreign keys)
- Representative values, through column profiling
This is the foundation of SQL generation. But sending the entire warehouse schema to a model is rarely practical: it adds noise, raises cost, and makes it easier to pick the wrong table. A better approach is to find the likely relevant tables first, then load only that part of the schema. Good agents work like good analysts. They don’t read the whole warehouse before answering a question.
Query history from technical power users, aka data experts
Organizations ask the same kinds of questions over and over. A context layer can use historical successful queries, especially ones reviewed by experienced analysts, as examples of how the business expects a question to be answered. These historical queries should not be used raw; to be useful, they should be mined offline for relevant signals like:
- Trusted join paths and filters
- Used tables
- Standard date logic
- Established reporting conventions
- Semantic meaning and intent of the question using SQL-to-text methods
Often a new question differs from an old one only by a date range, a region, the sort order, or a filter. In those cases, safely adapting a trusted query can be more reliable than writing a new one.
When the change touches the core logic, such as joins, aggregations, or which measures are selected, the agent should write a new query instead.
Historical context is where your best analysts’ knowledge can be leveraged across the whole company. One expert’s reviewed query can guide hundreds of future answers.
An integrated Evals suite for the data team
Evals are the tool that lets data teams deploy data agents safely and responsibly to the rest of the organization.
Running evals offline on a defined test set of golden question-answer pairs and measuring performance using execution accuracy is the safest way to evaluate the quality of the agent and of the context before onboarding real users. These offline evals can and should be used to continuously monitor agent performance and the impact of any context layer change. Defining the test set is a joint effort between business and data teams, and it should be as representative as possible of real business questions people have.
In addition to offline evals, allowing the data team to monitor online evals via user feedback—every correction provided by the user to the agent should be collected and exposed to the data team that can analyze it, and use it to enhance the context provided to the data agent.
The second pillar is business context from business experts and stakeholders
Business context describes what the data means and how it should be used. This is where most of a context layer’s value lives, and it’s the part most often missing.
It includes:
- Metric definitions governed in one semantic layer
- Natural language business context: a glossary of key business terms, domain-specific rules and standard operating procedures encoded in skills and instructions, all in natural language
- User and chat-level skills and instructions
We will explain these different components and how they interact in a future post, but we will focus for now on the governance of business metrics and the semantic layer.
One semantic layer is the core of your context layer
If you take one idea from this article, take this one: you can’t have a reliable data agent without a semantic layer. A semantic layer defines your business metrics once, centrally, in a form machines can read. “Net revenue” stops being a calculation each analyst writes differently and becomes one governed definition: which table, which filters, which aggregation, which time dimension.
When an agent gets a question about churn, it can choose the governed “Churn” metric instead of rebuilding the logic from raw tables.
The industry is converging on this idea. Semantic layer tools, warehouse-native semantic models, and open standards efforts are all trying to make metric definitions portable across BI tools and AI agents. The reason is straightforward: an agent that picks a governed definition is far more reliable than one that has to invent a calculation every time.
Consider this question:
“How many active customers did we have last month?”
“Active customer” carries several business decisions. Is it someone who logged in? Made a purchase? Kept a subscription? Passed a usage threshold?
The database can’t answer that from its structure. The organization has to supply the definition, and the semantic layer is where this central definition should be created and maintained.
The third pillar is governance signals from the governance team
A context layer that was accurate six months ago can become rotten today:
Tables get deprecated. Metrics get redefined. Teams reorganize. A query that was correct last year now joins a retired table. The agent doesn’t know any of this. It uses stale context with full confidence—which makes stale context worse than no context!
The fix is to treat ownership and governance signals as part of the context layer itself, not as a separate process.
Every asset has named owners
Every table, domain, metric, semantic model, and skill should have at least two named owners. Two, because people change roles, go on leave, and leave companies. An asset with one owner becomes an orphan the day that person moves on.
Owners review their assets, approve changes, and answer when something looks wrong.
Flag stale assets automatically
Anything not reviewed within a set window—for example three months—should be flagged automatically. A flag doesn’t mean the asset is wrong. It means someone should confirm it is still right.
Agents can use freshness too. A recently certified metric should carry more weight than one nobody has looked at in a year.
Propagate deprecation through lineage
When something upstream changes, everything downstream should know.
If table A is deprecated, every metric, semantic model, saved query, chart, and skill that depends on it should be flagged, either automatically through lineage or manually by owners. Otherwise the agent keeps reusing a trusted query that no longer works.
table_a (deprecated)
├── metric: monthly_revenue → flagged for review
├── semantic model: orders → flagged for review
├── saved query: "Q3 revenue" → excluded from reuse
└── chart: revenue dashboard → owner notified
Learn from usage
Agent usage tells you how healthy your context is. Questions the agent can’t answer, terms it can’t find, and corrections users make all show where context is missing or wrong. A good context layer turns those signals into work for the right owners.
Why the context layer should be “headless”
Your company is not using one AI agent: your data team might use a specialist analytics agent. Your engineers use coding assistants. Your executives use an enterprise chat assistant from one vendor or another. Your support team uses something else. New agents will keep arriving.
If each agent has its own context—with its own definition of “revenue,” its own idea of which tables are trusted, and its own permissions—you get the chaos the context layer was meant to end: different answers to the same question, depending on which tool you asked. So the context layer should be headless: separate from any single agent, a substrate, a single source of truth that any agent can query, including your own data agents, third-party assistants, and enterprise AI platforms. Emerging standards such as the Model Context Protocol (MCP) make this practical. You expose your context layer once, and any agent can use the same governed definitions, trusted examples, and permissions. Ask “what was net revenue last quarter?” in any of those agents and you should get the same answer.
People should be able to ask where they already work: Slack, Microsoft Teams, Google Chat, email, embedded in a BI tool, or in a dedicated app. The interface changes. The context, definitions, and permissions stay the same.
A headless context layer also protects your investment. Models will change. Agent frameworks will change. Chat tools will change. Your business definitions, governance work, and accumulated knowledge shouldn’t have to be rebuilt each time.

A context layer is your most strategic asset
Organizations racing to deploy data agents should ask “what does our data agent actually know about our business?” Answering this question right gives you an edge over competitors who also have access to the same LLMs as you. What competitors cannot copy is your context layer: every certified metric, reviewed query, and clarified term makes every agentic answer more reliable, across every agentic harness and every chat surface.
If you want agents that produce trusted work at scale—answers your teams can act on without double-checking every number—start with context, not the model.
Build the context layer first, govern it well, and magic will follow.
The perfect context layer
A reliable context layer is headless, evergreen, governed, and collaborative—the combination that lets every agent and every UI share the same trusted definitions.
PS: We implemented most of these ideas in our own agentic analytics platform: Unity Layer. If you want to know more, reach out here.
We also made this short survey to help you assess your data and context readiness for data agents: Data Stack Maturity Assessment.