All Posts

Context Layer: What It Is & Why AI Analytics Needs One In 2026

by Rick Radewagen6 min read

A context layer is everything an AI agent reads before it queries your data: what each metric means, which tables are trusted, how they join, the caveats people learned the hard way, and their corrections. A semantic layer computes a metric; a context layer tells the agent which metric the question meant.

I co-founded GetDot, an AI data analyst, so I have a stake here; what follows comes from watching customers build theirs.

What is a context layer?

Almost every vendor defines the term as what it already sells: agent memory (Redis), the catalog (DataHub, Atlan's "enterprise context layer"), the semantic layer (Cube) or the warehouse (Snowflake).

For analytics, I use a narrower definition: what a good analyst tells a new hire. Which numbers are official, where they live, and what people confuse them with. One customer asked for a pull request on every change to its sources, notes and skills: "This way we could review each change on our context layer."

What goes into a context layer for analytics

Component

Example

How the agent uses it

Metric glossary

"Revenue means net recognized revenue unless the question says bookings"

Picks the right metric for a vague question

Table and column docs

"fct_orders is the source of truth; orders_raw includes test orders"

Finds the right table

Join relationships

Orders join customers on customer_id, many to one

Avoids fan-out and double counting

Semantic layer (if any)

A Malloy, LookML, dbt or DAX measure

Computes governed metrics the same way every time

Caveats

"Ignore orders before the 2024 migration"

Applies filters the schema does not show

Trusted questions

"Q3 net revenue was X", checked by finance

A test suite for the rest of the layer

Corrections log

"For churn, use the subscription explore"

Stops repeat mistakes

The agent reads names and descriptions on every question and trusts them over the schema (your data model is the prompt), so a stale description is worse than none.

A worked example: "What was revenue last quarter?"

"Revenue last quarter" can mean eleven different things. Orientation decides which one the person meant. Computation applies it with the right filters, grain and joins.

Orientation is a short note in plain language:

Revenue. Unqualified "revenue" means net recognized revenue: the net_recognized_revenue measure on invoices, by recognition date. Bookings (signed contract value) is a sales metric; use it only when the question says bookings, pipeline or signed. Owner: finance analytics.

Computation is a measure in a semantic layer, here in Malloy:

source: invoices is duckdb.table('analytics.fct_invoice_lines') extend {
  primary_key: invoice_line_id

  measure:
    #" Recognized revenue net of refunds and credits, excluding test accounts
    net_recognized_revenue is sum(amount - refund_amount - credit_amount) { where: not is_test_account }
}

run: invoices -> {
  where: recognized_at ? @2026-Q3
  aggregate: net_recognized_revenue
}

Without the note, the agent may compute bookings perfectly. Without the measure, it may write the right formula three ways in three chats. The semantic layer guide shows the full model and the SQL it compiles to.

Why AI analytics needs one: the evidence

  • Business Analytics Bench. In our benchmark of real analyst work, GetDot, Snowflake's Cortex Agent and Databricks Genie got the same written notes, as instructions and table comments, and declared joins. We defined no metrics for anyone. GetDot Frontier scored 88.0, Cortex Agent 77.6 and Genie 39.9. We built the benchmark and GetDot, so weigh it with that in mind.
  • Pinterest. Table search hit 40% without table documentation and up to 90% with it (Pinterest's text-to-SQL write-up).
  • Ramp. Domain documents are the map to the metrics, the semantic layer computes each one (Ramp Research).
  • OpenAI. Its internal data agent reads six layers of context before it writes SQL.
  • Anthropic. Its agents consult a semantic layer first, with definitions written by hand, because model-drafted ones made results worse (Anthropic's write-up).

Across 14 companies that built their own AI analysts, the model is rented and the context is the work.

Context layer vs semantic layer (and ontology)

A semantic layer computes metrics deterministically. A context layer orients the agent (which metric, which table, which caveat) and contains the semantic layer. An ontology models what things exist and how they relate. See ontology vs semantic layer vs context layer for one question worked through each.

Semantic layer AI: is a semantic layer enough?

No. It solves computation, not orientation, and when a question lands outside it, the agent guesses anyway. Having both also creates a routing problem. A customer adding Cube next to its gold layer settled on the clearest rules I have seen:

  • Use the semantic layer only when an approved measure covers the requested dimensions, filters and grain; otherwise use the gold tables.
  • A missing metric is not a failed query. An access error must never fall back to the warehouse silently.
  • Formulas move into the semantic layer. Terminology, synonyms, caveats and source-selection rules stay in context.

How to build a context layer in six steps

  1. List the 20 questions people actually ask.
  2. Document only the tables those questions touch. Turn the others off.
  3. Write the map in prose. One short note per metric or entity: definition, a SQL example, its tables and what it gets confused with.
  4. Make the metrics that must match deterministic. Board and finance metrics go into a semantic layer.
  5. Save trusted questions with known answers as tests. One customer's QBR dashboard became 231 test questions and 123 metric notes, until Dot matched it on all 231.
  6. Route every correction through review. "For X we always use metric Y" should become a proposed change an owner approves, not a silent edit.

Keeping it current

A context layer drifts the moment someone renames a column. Version it, review every change, and test before you merge. A rewrite is a production change. One customer's clean-up split 112 notes into 150. Notes loaded per question went from 12 to 52 (median), cost rose, and the default table for a recurring metric quietly changed: the same daily question returned two totals five days apart. Re-run your trusted questions after every rewrite.

More context also costs time. The same question took 10 minutes and 9.4 credits in a broad workspace, against 1.1 minutes and 1.5 credits in one scoped to a single domain. Split by domain.

Build vs buy, and who should own it

Catalogs (see our data governance tools roundup), semantic layer vendors, warehouses and AI analysts all want to hold your definitions. Resist all of us, ourselves included: keep definitions as files in a Git repository you own, readable by any agent.

The data team is the natural owner, and it becomes the context team. Build the agent if you have the engineers, as Ramp and OpenAI did; otherwise buy, and keep the context portable.

How GetDot builds and maintains your context layer

Dot reads the definitions you have: dbt, LookML, Power BI semantic models, Cube and Malloy. The Model page shows how often answers used each note over the last 90 days.

The Context Agent (Root) builds the rest from dbt, Looker, Tableau, Power BI, Sigma, Metabase, Malloy and Cube, from docs in Notion, Confluence and Google Drive, and from warehouse query history. Every change, including a correction made in chat, arrives as a proposal with a readable diff, tested in an isolated environment and optionally opened as a GitHub pull request. Train tests Dot against trusted questions and fixes the context until answers match. When the context does not settle something, Dot marks the answer "Assumption made". Dot is also an MCP server, so other agents use the same agentic analytics loop and context.

FAQ

No. A semantic layer defines how metrics are computed. A context layer includes it, plus what tells an agent which metric a question means.

No. A catalog inventories data assets for people. A context layer is the smaller, opinionated subset an agent reads: the official definitions and the traps.

No. Start with prose notes and trusted questions. Move metrics into a semantic layer once they stabilize or must match across tools.

The same idea at company scale, read by many agents and teams. Split it by domain, because one giant layer makes every answer slower and more expensive.

Through search and file reads, or through MCP servers that expose its definitions. Markdown files in Git work best.

Want to see your own context layer at work? Point the Context Agent at your dbt project or dashboards and review the first proposals it drafts.

Rick Radewagen

Rick is a co-founder of Dot, on a mission to make data accessible to everyone. When he's not building AI-powered analytics, you'll find him obsessing over well-arranged pixels and surprising himself by learning new languages.

Read more