Why your data agent gets metrics wrong

October 2026 ยท 6 min read

Give Claude or Cursor read access to your warehouse and it will happily answer "what was revenue last month?" The SQL will run. The number will look plausible. And there's a good chance it's wrong.

Not because the model can't write SQL. Modern models write excellent SQL. It's wrong because the answer depends on decisions that live in people's heads, not in the schema.

The failures are almost never syntax

When we look at logs of agents answering real business questions, the wrong answers cluster into a handful of types:

None of these is visible from information_schema. Every one of them is something a human analyst learned by being corrected once.

Why a semantic layer alone doesn't fix it

The textbook answer is "build a semantic layer": dbt MetricFlow, Cube, LookML. They're great, and if you have one, your agent should use it. But for most small and mid-size teams there are three problems:

  1. It's never complete. You model the 20 metrics on the exec dashboard. People ask about the other 200.
  2. It goes stale. The YAML gets written once, during a big modelling push, and drifts from how the business actually talks.
  3. Nothing measures it. You have no idea whether your agent is right 60% or 95% of the time, so you can't tell whether all that YAML helped.

The fix: capture corrections where they happen

The highest-signal moment in the whole system is when a human says "no, that's wrong, revenue should exclude refunds". Right now that knowledge evaporates: it fixes one chat, on one laptop, for one person.

A better loop:

  1. Before writing SQL, the agent looks up the team's definitions relevant to the question.
  2. When a human corrects it, the agent records the correction as a proposed rule.
  3. A human approves it (one click), and from then on every agent on the team gets it right.
  4. Every question is logged as confirmed or corrected, so you get an accuracy number per week and can see it move.

This is cheap to run because the agent does the work: it already knows when it's been corrected. You just need somewhere shared to put it, and a way to serve it back.

Doing it yourself

You can get 80% of this with no tooling at all:

It works, and it's a good way to discover how many of your agent's errors are definitional (in our experience: most of them).

Or use Contextloop

We built Contextloop to do exactly this loop without the spreadsheet. It's an MCP server your agent calls: get_context before writing SQL, report_outcome when you confirm or correct an answer. Corrections arrive in a review queue, approved definitions are served to every agent on the team, and the dashboard shows weekly accuracy. It never touches your warehouse. Your agent keeps using its own database tools. You can export everything to Markdown, dbt MetricFlow or Cube YAML at any time.

It's free to start and takes about two minutes to connect to Claude Code or Cursor.

Try Contextloop free

Questions, or want us to run a free accuracy pilot on 50 of your team's real questions? Email delphine.taylor@kivamail.com.