Your agent has the schema. It doesn't know the business.

A few weeks ago we followed an agent through a simple question: how many shipments were late since July? It found the right table and wrote reasonable SQL. Then it ran this four times:
| Filter | Status | Rows |
|---|---|---|
WHERE status = 'late' | Success | 0 |
WHERE status = 'Late' | Success | 0 |
WHERE status = 'LATE' | Success | 0 |
WHERE status = 'overdue' | Success | 0 |
The value it needed was 'DELAYED'. The agent had the schema, and the schema said status VARCHAR. That's true, but it doesn't help. Nothing in the agent's context said which statuses exist, which one means "late", or that a 0 here almost certainly means the filter is wrong.
The usual fix is more context: paste the DDL, add sample rows, put the data wiki behind a retriever, write a longer system prompt. It's called context engineering now, and it does help. But for data agents it keeps running into three problems:
- The schema describes storage, not the business. It tells you a column is a
VARCHAR(1). It doesn't tell you thatBmeans weather, that delays are in minutes, or what makes two customer rows the same customer. - Prompt context is a suggestion. Nothing checks whether the agent used it. A sample row that shows
'DELAYED'competes with the word "late" in the question, and the question often wins. - Every agent rebuilds it. The Claude Code setup, the in-house Slack bot and the BI copilot each write their own notes about what the data means. That's the three-revenues problem again, now in prompts.
Context in a prompt is a hint. Context in the query path is a contract.
Four kinds of context a data agent needs
"Context" covers several different things. For an agent answering questions over data, it helps to split them by the question each one answers:
| The agent needs to know | Context | Where it lives today | Open format |
|---|---|---|---|
| What's stored? | tables, columns, types | the catalog | Apache Iceberg, Iceberg REST |
| What do the numbers mean? | metrics, joins, grain | a semantic layer | Apache Ossie semantic model |
| What are the things? | concepts, identity, relationships, allowed values, units | wiki pages and people's heads | Apache Ossie ontology (in development) |
| What may I see, and what did I already do? | access policy, guardrails, history | the query path | — |
Agents mostly get the first row, because that's what information_schema returns. The second row is what the Ossie posts covered: give agents named metrics instead of joins, and a compiler that won't double count. The fourth row can't be written in a format at all. It depends on who is asking, at runtime, so something on the query path has to enforce it.
This post is about the third row. It's the one most teams have never written down in a form a machine can read.
What an ontology adds
"Ontology" sounds like a knowledge-graph project that takes a year and never ships. The version Apache Ossie is drafting is much smaller. Its spec says ontologies are "conceptual models of enterprise data that describe the enterprise in terms of concepts, relationships, and business rules." In practice that's a YAML file next to your semantic model.
Here's a trimmed piece of the flights example from the Ossie project:
ontology:
- concept: CancelationCode
type: ValueType
extends: [ String ]
requires: [ CancelationCode == 'A' OR CancelationCode == 'B' OR CancelationCode == 'C' OR CancelationCode == 'D' ]
- concept: Delay
type: ValueType
extends: [ NrMinutes ]
- concept: CancelationReason
type: EntityType
identify_by: [ code ]
relationships:
- name: code
roles:
- concept: CancelationCode
verbalizes: [ '{CancelationReason} is identified by {CancelationCode}' ]
multiplicity: OneToOne
Each part answers something the schema can't:
- Allowed values.
requiressays a cancellation code is A, B, C or D. An agent that filters on'weather'is wrong before the query runs, and a machine can tell. - Units.
DelayextendsNrMinutes. A column calleddep_delay DECIMALdoesn't say whether to divide by 60 before reporting hours. - Identity.
identify_bysays what makes two rows the same thing. "How many customers?" means distinct customers by that identifier, notCOUNT(*)over a table that has one row per address. - Relationships the model can read.
verbalizesturns each relationship into a sentence: a CancelationReason is identified by a CancelationCode, a Route connects to a departure Airport. That's prompt text that comes from the model itself, so it can't drift away from it.
Separate mapping documents connect concepts to the datasets and fields of an Ossie semantic model, using SQL expressions, so one concept can draw on several tables. That's the gap the project's roadmap names: Ossie "currently solves structural interoperability — any tool can read and write semantic models in a common format — but it does not yet solve conceptual interoperability, where different models may describe the same business concept using different names or structures."
It's early. The ontology spec is at version 0.3.0.dev0, marked unreleased. The spec says "parser and converter support for standalone mapping documents is not yet available". The work happens in the project's Ontology & Semantic Interoperability working group. ossiec, our compiler, reads Ossie semantic models today. When it gets an ontology document, it rejects it with a clear error and doesn't guess.
Better context, because you can check it
Here is the part that matters for agents. Descriptions, sample rows and wiki pages are written for a reader. An agent may read them or ignore them, and you can't tell which. An ontology is written for a machine, so a machine can check the agent's work against it.
This is the design direction we're exploring for QueryFlux. None of the checks below ship today.
- Reject values that can't exist, before execution. If
flights.cancellation_codemaps toCancelationCode, then= 'weather'breaks arequiresrule. Instead of a confident0, the agent gets an error it can fix:'weather'is not a CancelationCode; allowed: A (carrier), B (weather), C (national air system), D (security). Our earlier posts made the same point: errors an agent can fix in one retry are worth more than a clean result that's wrong. - Label results with concepts. A column that comes back as
Delay (NrMinutes)tells the agent the unit. It doesn't have to guess from the column name. - Count things, not rows. A semantic request for "customers" compiles to a distinct count over the concept's
identify_byfields, the same way ossiec already uses primary keys to avoid double counting. - Look things up by concept, not by table. An agent that lists twenty business concepts with their relationships reads far less than one paging through four hundred tables of DDL, and it's more likely to start in the right place.
Some of these could be done with a richer catalog comment or a stricter CHECK constraint. The difference is where the knowledge lives: in one open document that every tool reads, rather than spread across each engine's metadata and each agent's prompt.
Why the query path, and not the agent framework
You could build all of this into one agent. Plenty of teams do. The trouble is that it then belongs to that agent. Putting it in the query path, where QueryFlux already sits, buys you a few things:
- Every client gets the same context. Claude Code, Cursor, your in-house agent and the dashboard all go through one endpoint, so they all see the same concepts and hit the same checks.
- Meaning and permission live together. The ontology says a Customer is identified by
customer_id. A row filter says this caller only sees their own tenant's customers. Both apply to the same query, in the same place. A concept can't become a side door around a policy. - The record shows where context is missing. Query history already shows which agent ran which query. Add concepts, and it also shows which values agents keep guessing wrong. That list is a to-do list for whoever maintains the model.
- It's versioned like code. Models come from Git, and each model reports the commit it was loaded from.
What exists today, and what doesn't
Available now
- ossiec (Apache-2.0) compiles Ossie semantic models into SQL for Trino, StarRocks, ClickHouse, Snowflake, DuckDB, Postgres and more. It's tested on six real engines.
- QueryFlux's MCP frontend, guardrails, row filters and query history for agent traffic.
In development, not in a release yet
- A semantic model registry in QueryFlux, synced from a Git repository. If a sync brings in a broken model, QueryFlux keeps serving the last version that validated.
- MCP tools for agents:
list_semantic_models,describe_semantic_model(metrics, dimensions, relationships and each model'sai_context),query_semantic_modelandcompile_semantic_query. - A working demo runs these tools on Iceberg tables, with DuckDB and Trino in one group. QueryFlux has ossiec compile each request once for each engine, so the same question returns the same answer on both.
Exploring
- Reading Ossie ontology documents and their mappings, value checks before execution, and concept labels on results. We'll follow the spec as it settles rather than invent our own format.
What could go wrong
- Ontologies have a history of never being finished. The semantic web spent twenty years modeling everything. The useful part for agents is small: allowed values, units, identity and a handful of relationships, for the concepts people actually ask about. Start there.
- Rules drift from data. If a new code
Eshows up in the data and the ontology still says A to D, a strict check turns a valid query into an error. Value checks need a warn mode, and they need testing against the real data, before they can block anything. - The spec will change.
0.3.0.dev0means what it says. Anything built on it now should expect to be rebuilt.
None of this replaces a good model or a good prompt. It changes what the prompt has to do. An agent that can look up what things are, and gets told right away when it's wrong about one, doesn't need you to anticipate every 'late' it might type.
Read the Apache Ossie ontology spec and the roadmap, try ossiec on your own semantic model, and see how QueryFlux already handles agents and row filters on one query path. If you're modeling concepts for agents, we'd like to hear what you put in first.
