comparison
comparison8 min read

What Is the Difference Between a Semantic Layer and a Context Layer for AI Data Agents?

One defines what your metrics mean, the other decides what an agent sees at each step, and they overlap in three places

A semantic layer holds governed business definitions (metrics, dimensions, entity relationships) and compiles them into SQL, while a context layer decides what an AI agent can see at each reasoning step and treats those definitions as one input among several. Redis's engineering team frames the split the same way: semantic modeling and AI grounding solve different problems under different runtime constraints. We agree with the framing and think it leaves out three things, which we cover below: provenance, policy and identity.

Key Takeaways

  • •A semantic layer answers "what does this metric mean?" It is deterministic, stateless and produces SQL against structured warehouse data.
  • •A context layer answers "what should this agent see right now, and is it allowed to?" It runs on every inference call and spans documents, memory, tools and permissions.
  • •The context layer is a superset: semantic definitions are one of its inputs, not a competitor to it.
  • •The two layers overlap in three places that decide whether an answer is trustworthy: provenance (where a value came from), policy (who may see it) and identity (who is asking).
  • •A production data agent needs both. The semantic layer keeps the numbers right, and the context layer keeps the agent on task, permissioned and auditable.

What a semantic layer holds

A semantic layer stores business meaning on top of physical tables. Snowflake's documentation describes its semantic views as schema-level objects that hold five kinds of definition: logical tables, relationships, facts, metrics and dimensions. Snowflake treats them as metadata, which is the useful property. Nothing is copied. The layer records that "revenue" means a specific aggregation over a specific join path, and every consumer inherits that answer.

This is why a semantic layer is the right fix for the "three dashboards, three definitions of customer acquisition cost" problem. You define the metric once, usually in YAML or SQL DDL, and the layer compiles downstream queries into the right SQL. The consumer might be a BI tool, an API or a text-to-SQL agent. The definition has one owner and one place to change.

Three properties follow from that design, and all three are strengths for BI: the output is SQL, the architecture is warehouse-oriented, and each request is processed independently. A dashboard does not need to remember what you asked an hour ago. An agent does, which is where the two layers start to diverge.

Where a semantic layer stops for AI agents

The same Redis post lists five gaps that appear once you point an agent at a BI-style semantic layer: no native vector search, batch refresh instead of inference-time freshness, no memory across turns, no validation of generated output, and no support for unstructured data. We would add a sixth from our own work on data agents: a metric definition tells an agent what "revenue" means, but not whether this user may query it or whether the underlying table is still trustworthy.

The statelessness point deserves attention. An agent that investigates an incident works across many turns: it checks a schema diff, then a lineage graph, then a freshness score, and each step depends on the last. A semantic layer exposes stateless APIs, so nothing in it records what the agent already tried. Something else has to carry that working state.

None of this is a criticism of the semantic layer. It does one job well, and we would not ask an agent to guess metric definitions from table names when a governed definition exists. Our earlier posts on text-to-SQL versus a semantic layer cover that failure mode in detail. The point here is narrower: a layer built to translate metric queries into SQL was never meant to assemble an agent's working context.

What a context layer holds

A context layer governs what populates the model's context window at each step. Redis lists its typical contents: retrieval pipelines, short-term and long-term memory, tool definitions, permission and governance filtering, semantic definitions and system instructions. The Model Context Protocol gives the tool and data side of this a standard shape. Its resources specification lets servers expose files, database schemas and application data to clients, each identified by a URI.

The MCP spec also shows how a context layer prioritises. Resources carry optional annotations, including a priority value from 0.0 to 1.0 where 1 means effectively required, and an audience field that marks content for the user, the assistant or both. Those fields exist because the context window is finite and something has to rank what goes in. A semantic layer has no equivalent concept, since a SQL query returns whatever it was asked for.

For a data team, the practical contents of a context layer are the schema and lineage of the tables involved, the semantic definitions that apply, recent incidents and their resolutions, the caller's permissions and the tools the agent may invoke. Our Catalog Agent assembles the discovery and lineage portion of that, and our Insights Agent consumes it when it writes an analysis with its assumptions stated.

Where the two layers overlap: provenance, policy and identity

Both layers touch the same three questions, and answering them in two places is how teams end up with contradictory results. The first is provenance: where did this value come from? A semantic layer knows the metric's definition and the tables it reads. A context layer knows which version of that definition the agent used, which sources it retrieved and what the data's freshness was at query time. A trustworthy answer needs both records attached to it.

The second is policy. A semantic layer can enforce row-level or column-level rules at query time, and a context layer filters what an agent is authorised to retrieve before it reaches the model. If those two rule sets are maintained separately, they drift. The agent may be blocked from a PII column in the query path while the same column's sample values sit in a retrieved document. Policy has to be one source feeding both layers.

The third is identity. A semantic layer typically sees a service account, and a context layer needs to know which human or which agent is acting and on whose behalf. MCP's resources spec says servers MUST validate resource URIs and SHOULD implement access controls for sensitive resources, but it leaves the identity model to the implementation. This is the overlap we think the "superset" framing glosses over, because identity decides whether a correct metric reaches the right person.

How the layers fit together in five steps

We find it easiest to think of the pairing as five steps on every agent request. Each step names which layer owns it, so you can see where the handoffs happen and where a failure would surface.

  • •Step 1, identity: the context layer resolves who is asking and which policies apply.
  • •Step 2, retrieval: the context layer pulls the schemas, lineage, documents and prior state relevant to the question, ranked to fit the window.
  • •Step 3, meaning: the semantic layer supplies the governed metric and dimension definitions the question refers to.
  • •Step 4, execution: the semantic layer compiles those definitions to SQL and the warehouse runs it under the caller's permissions.
  • •Step 5, record: the context layer stores the answer with its provenance (definition version, sources, freshness) so a reviewer can reproduce it.

Notice that the semantic layer owns only steps 3 and 4. The rest happens around it. That is the practical meaning of "superset": the context layer wraps the semantic layer's output and carries it through identity, retrieval and audit.

How Data Workers approaches the pairing

We build Data Workers as fifteen MCP-native agents that share context across ingestion, transformation, quality and governance, so the context layer is the shared state the agents already use. When an agent in Claude Code or Cursor asks "what's the blast radius if I drop this column?", the schema and catalog agents answer from the same lineage, and the semantic definitions are one of the inputs they read. We do not replace a semantic layer you already run. We read from it.

The open-source edition runs locally and is read-only by default, which matters for the policy overlap above: an agent cannot write its way around a rule it was never allowed to break. Pro adds writes with approval workflows and audit trails, so the provenance record in step 5 is tamper-evident rather than a log someone can edit. Data stays in the customer's infrastructure.

Where we differ from a pure retrieval-and-memory framing is on what comes after the answer. Knowing the right metric is half the job. The other half is acting on it, such as diagnosing the incident, mapping the blast radius and deploying the fix, and that needs agents that share the same context rather than one tool per slice.

Frequently Asked Questions

Is a context layer just a bigger semantic layer?

No. It is a different kind of system. A semantic layer is a deterministic translator from metric definitions to SQL. A context layer is a runtime that assembles what a model sees on every call, including unstructured documents, memory and permissions. It contains semantic definitions as one input, which is why people call it a superset, but it solves a different problem on a different timescale.

Do I need a context layer if I already have a semantic layer?

If your agents only run governed metric queries for a single user, a well-maintained semantic layer may be enough. Once agents work across multiple turns, mix documents with tables, act on behalf of different users or take actions rather than just answer, you need something that carries state, filters by permission and records provenance. That something is the context layer.

Can the two layers share the same access policies?

They should. Policy maintained separately in each layer will drift, and the drift shows up as an agent that is blocked in one path and exposed in another. Define access rules once, enforce them in query execution and in retrieval filtering, and log both decisions in the same audit trail.

Where does MCP fit?

MCP is the transport and shape for the context layer's tool and data access. The resources specification defines how servers list, read and subscribe to data, and returns a standard -32002 error when a resource is not found. A semantic layer can be exposed to agents through MCP, which is how it becomes one of the context layer's inputs.