Guide · Comparison

Context layer vs semantic layer vs RAG vs agent memory: when to use which

For architects choosing how to give agents knowledge of the business.

Updated

Use a semantic layer when you need governed, consistent metrics over structured data. Use RAG when an assistant should answer from a body of documents. Use agent memory when an agent should remember a user's preferences and past sessions. Use a context layer when several agents need one reviewed, shared model of how the business works, spanning schema, documents, events and procedures. They overlap, and many teams use more than one.

  • Each approach has a typical failure mode; pick by the failure you can least afford.
  • A semantic layer is not built for documents or events; RAG returns passages, not definitions; memory is usually per user and unreviewed.
  • A context layer costs more to set up and needs curation.

Semantic layer

A semantic layer defines metrics and dimensions once over structured data so every tool computes them the same way. Strong for consistent numbers. Failure mode: it only covers what has been modeled in it, so documents, events, rules and procedures are outside it, and it does not say which table or policy an agent should use for a question that is not a metric.

RAG (retrieval-augmented generation)

RAG retrieves passages from a corpus at query time and gives them to the model. Strong when the answer is written in a document, and simple to start. Failure mode: it returns text, not definitions. Two documents can disagree, an old one can outrank a new one, and nothing records which wins or that a term means something specific in your business.

Agent memory

Memory stores what an agent or user said or learned so a later session can use it. Strong for personalization and continuity. Failure mode: it is usually per user and per tool, and unreviewed, so one person's wrong note persists and a colleague's agent never sees what yours learned.

Context layer

A context layer holds a reviewed, shared model of the business: structure, documents, events and procedures, served to every agent. Strong when meaning lives in people's heads and several agents need the same view. Failure mode: it needs setup and curation, its quality depends on your sources and on people reviewing what ingestion proposes, and it does not replace your systems of record or your guardrails.

Scenarios and the best fit
ScenarioBest fitWhy
Dashboards and agents must agree on revenueSemantic layerGoverned metric definitions over structured data
An assistant answers questions from a policy handbookRAGThe answer is in a passage of text
An assistant remembers a user's preferences across sessionsAgent memoryPer-user, session-spanning state
Several agents need to know which table backs which entity and which rules applyContext layerShared, reviewed structure plus documents
You need to know what was decided or what happened about an accountContext layerTraces and briefs tied to entities
One agent, a few documents, low changeRAGSimplest thing that works

FAQ

Does a context layer replace RAG?
No. Retrieval over documents is one part of it (BrainBox has full-text search over wiki pages). A context layer adds typed, reviewed structure and shared state on top.
Is a context layer a semantic layer?
They overlap on metrics. The Brain stores metric definitions as catalog records and its built-in compiler covers single-grain aggregations; for governed BI metrics a dedicated semantic layer may suit you better.
Is a context layer agent memory?
Part of it is: traces, personal pages and learnings. The difference is that shared knowledge is reviewed and applies across agents and people, not one user's history.
Can I combine them?
Yes. A common setup is a semantic layer for KPI numbers, a context layer for meaning and rules, and memory for personal preferences.

Give your agents a brain.

Sign in and ask your first question.

Book a Demo