Demo · Context Layer for AI Agents · under the hood

How the demo is built

What the context layer demo is made of and how it works: the architecture, the data, the traps in the data, the catalogue content and the agent’s path to an answer. The measured results and the limits are on the demo page.

Fictional Bank (Fikcyjny Bank S.A.) · synthetic data · fictional company

Back to the demo results

How it is built

The two modes differ only in the list of tools the agent can see. The system prompt, the model, the settings and the answer format are the same.

User question

Agent

my own Python program and a Claude model

MCP · read-only

Data warehouse

PostgreSQL · 2 SQL tools

both modes

Company catalogue

OpenMetadata · 3 catalogue tools

context layer only

  • As-is. The agent sees tables, columns and database comments, as in a typical warehouse. The technical description is accurate: types, keys, the sign of an amount, the currency. Business definitions are missing and some descriptions are out of date.
  • With the context layer. The same, plus three catalogue tools: search, entity details and data lineage. Before its first step the agent fetches its working procedures from the catalogue. Their text lives in the catalogue, not in the prompt.

The data: a fictional bank’s warehouse

customers
5,000
accounts
8,131
transactions
806,899
months of data, 1 January 2025 to 30 September 2026
21

PostgreSQL, 7 schemas, 9 tables and 1 view. The data comes from a deterministic generator with a fixed seed, and its checksums are in the repository, so every run works on an identical database. There are no first names, surnames, addresses or numbers resembling real identifiers.

The as-is mode is not weakened for the show: the database comments are correct. The difference is what the catalogue says about the same column.

  • core.klient.segment
    Database comment (as-is)
    Customer segment: retail, premium, micro-business.
    Catalogue description (abridged)
    The segment as of the day the relationship started. It is a copy that is not updated. The source of truth is the CRM; owner: Sales and CRM Department.
  • core.transakcja.data_transakcji
    Database comment (as-is)
    Transaction date.
    Catalogue description (abridged)
    The date the transaction was made. Used for analysing customer behaviour. It does not set the period in reports: periodic reports go by posting date.
  • kyc.klient_kyc.dochod_deklarowany
    Database comment (as-is)
    Monthly income declared by the customer (PLN).
    Catalogue description (abridged)
    Monthly income declared by the customer (PLN). Sensitive: do not disclose values or aggregates.

Eight traps in the data

Each trap is a place where a query written straight from the schema gives a different result than the company’s definition. All of them occur in real companies.

  1. 1 · 11 questions

    Active customer and a change of definition

    An open account is not activity. What counts is a transaction initiated by the customer in the last 90 days, and from 1 July 2026 without transfers between the customer’s own accounts.

    as-is 0% → with context 99.6%

  2. 2 · 6 questions

    Transaction date or posting date

    Card payments are posted 1–3 days later. The monthly report goes by posting date.

    as-is 16.3% → with context 100%

  3. 3 · 5 questions

    Reversals and corrections

    The ledger is append-only: a reversal and a correction are separate entries linked to the original transaction. A plain sum counts both sides.

    as-is 9.3% → with context 100%

  4. 4 · 2 questions

    Currencies

    Amounts are in the account currency: PLN, EUR or USD. Flows are converted at the average rate on the posting date, balances at the month-end rate.

    as-is 2.2% → with context 100%

  5. 5 · 4 questions

    High-risk customer

    The model’s class is always filled in, the analyst’s decision only sometimes. The analyst’s decision takes precedence.

    as-is 39.5% → with context 100%

  6. 6 · 5 questions

    Sensitive fields

    Declared income, source of income and the AML note are tagged as sensitive data. The agent discloses neither values nor aggregates and names the owner of the data.

    as-is 25.3% → with context 100%

  7. 7 · 5 questions

    Conflicting sources and a deprecated view

    The segment in the transaction system is a copy from the day the relationship started, and the source of truth is the CRM. An old reporting view counts open accounts.

    as-is 0% → with context 100%

  8. 8 · 6 questions

    Data freshness

    One summary table holds data up to the previous day. The load of another stopped after 31 August 2026, while its database comment still says “loaded daily”.

    as-is 59.5% → with context 100%

Accuracy is the share of correct answers to the questions with a given trap: four models together, both question sets (tuning and held-out), runs at the models’ standard setting. One question can involve several traps.

What is in the catalogue

The catalogue content is code: YAML files in the repository, loaded into OpenMetadata through its API by a repeatable script. The whole stack can be rebuilt from scratch in about 2 minutes and yields the same catalogue.

Every definition has versions with an effective date and a status. The agent applies the approved version whose period covers the last day of the period in the question. It does not apply a version under review, but it mentions it.

DefinitionOwnerVersions
Active customerManagement Reporting Departmentv1 until 30 June 2026, v2 from 1 July 2026
Reporting period (posting date)Finance and Accounting Departmentv1
Turnover and transaction count (reversals and corrections)Finance and Accounting Departmentv1
Currency conversion to PLNFinance and Accounting Departmentv1
High-risk customerRisk and Compliance Departmentv1, v2 under review
Sensitive KYC/AML data: the agent’s access ruleRisk and Compliance Departmentv1
Customer segment: source of truthSales and CRM Departmentv1
Freshness and lineage of the summary tablesData Warehouse Teamv1
Deprecated view of active customersManagement Reporting Departmentv1

The agent’s two working procedures also live in the catalogue, not in the prompt:

  • Find the definition and pick the version in force. Six steps: from finding the term in the glossary, through picking the version by date and status, to stating the definition’s name, version and owner in the answer.
  • Sensitive data, conflicting sources, freshness, deprecated assets. Five rules: when to refuse and whom to name, which source is the source of truth, when a table is too stale to answer from, and what not to use for counting.

How the agent gets to an answer

The agent is my own Python program, about 1,750 lines including the measurement harness and the screen, built on the official Anthropic and MCP libraries. It uses no agent framework, so every model and tool call is recorded exactly as it happened.

  1. Question. The user asks in Polish. The system prompt gives the data date and asks for an answer card.
  2. Step 0, context mode only. The agent fetches its working procedures from the catalogue and adds their full text to the conversation.
  3. The model picks tools. It decides what to check: a definition in the catalogue, the database structure or data lineage.
  4. Tools over MCP. Calls go in parallel to the SQL server and to the catalogue.
  5. Loop. Results return to the model, which calls more tools or finishes. The limit is 25 model calls.
  6. Answer card. The final answer has an enforced format and is validated against a frozen schema.
  7. Trace and scoring. Every event goes into a trace. The measurement harness scores the card by the rules and computes the cost. The recording on the demo page is a replay of such a trace.

The answer card

The agent does not finish with loose text. It returns a card: the value, the period, the definitions used with their version and owner, the data sources, the assumptions, and flags for a refusal and for a source conflict. Automatic scoring and the definition panel on the demo screen both rely on the card. Field names are in Polish, as in the demo.

{
  "odpowiedz": "Na koniec sierpnia 2026 aktywnych było 3035…",
  "wartosc": 3035, "jednostka": "klienci",
  "okres": {"od": "2026-06-03", "do": "2026-08-31"},
  "definicje": [{"nazwa": "Aktywny klient — w. 2", "wersja": "2",
                 "wlasciciel": "Departament Raportowania Zarządczego",
                 "zrodlo": "katalog"}],
  "zrodla_danych": ["core.transakcja", "core.rachunek"],
  "odmowa": false, "konflikt": false, "konflikt_zrodla": [],
  "zalozenia": ["K = 2026-08-31", …]
}

Read-only: four layers

The agent cannot change anything in the database or in the catalogue. An automated test attempts a write through each layer and every attempt is blocked.

  1. Database. A read-only role and read-only transactions.
  2. SQL MCP server. Runs in read-only mode.
  3. The agent’s catalogue account. Rules deny writes, row samples and access to service configuration.
  4. Agent. An allowlist of tools, all of them marked read-only.

What next

The measured results, the method and the limits are on the demo page. I also show the demo live in 10–15 minutes.

Fikcyjny Bank S.A. (“Fictional Bank”) does not exist. All data in the demo is synthetic and the demo itself is in Polish. Models: Claude Fable 5.2, Opus 5.5, Sonnet 5.5 and Haiku 5.5. Catalogue: OpenMetadata 2.0.5.