How to Evaluate a Data Agent
Evaluate a data agent with golden questions, execution-match graders, and regression runs after every knowledge-layer change. Valid SQL is not enough.
TL;DR
A data agent is ready when it can pass a fixed set of real stakeholder questions, not when the SQL runs. Score three things separately: SQL correctness, answer correctness, and the explanation. Build a golden set from questions your team already asks, grade with execution-match first, and re-run the suite every time the knowledge layer or the semantic layer changes.
The picture at the top is an example scorecard, not a measured run. The same rows in text:
| Golden question | SQL | Answer | Explanation | First failing stage |
|---|---|---|---|---|
| Monthly revenue by region, October 2026 | Pass | Fail | Pass | report |
| Active users last week | Pass | Pass | Pass | pass |
On this page:
- What to evaluate
- A golden question set
- Graders
- Public benchmarks
- Regression runs
- The feedback loop
- What to track
- 3 things to do tomorrow
What should you evaluate: SQL correctness, the answer, or the explanation?
Score three separate checks. A query that runs is not a pass.
Read real traces before you write a check: the question, the tool calls, the SQL, the reply. Note the first failure on each one, name the modes, and test those. Do not start from a generic list.
Use pass or fail, one failure mode per check. A 1–5 score hides the boundary. A case passes only when every check that applies to it passes. Still store each check on its own. One pass rate does not say what to fix.
SQL correctness is the metric, source, filters, and grain. Answer correctness is the computed result against trusted gold on the same data, and the headline against what was computed. Explanation is whether the prose states the scope and stays faithful to the result.
Valid SQL is not enough. An unsafe failure, a confident wrong number or a number backed by no query, is a hard block on high-risk cases. A safe failure, an unnecessary clarifying question or a clearly stated reading the person did not want, gets a budget. Both are still pass or fail.
The same three scores, in text:
| Score | A pass means |
|---|---|
| SQL correctness | The query used the right metric, source, filters, and grain. |
| Answer correctness | The computed result matches trusted gold on the same data, and the headline matches that computation. |
| Explanation | The prose states the scope and stays faithful to the result. |
A data agent is not a chatbot with a warehouse login. That split is in Data Agents for Analytics Teams. This page is the suite around that worker.
How do you build a golden question set from real stakeholder questions?
Build it from questions people already asked, and keep the gate on the held-out slice.
Pull cases from tickets, chat, and production traces. Tag each as one or more of:
core: common questions, in people's own words.regression: a confirmed past failure.trap: tempts a known failure, such as an ambiguous word or a snapshot summed across a period.path: only one route is right.paraphrase: two to four phrasings of one high-risk question, onefamily_id.
risk_tier is high, medium, or low. High goes to leadership or finance. Medium is an operational metric. Low is an exploratory count.
Ten questions are a smoke test. At a true 80%, the 95% interval is about ±25 points: it can catch a broken domain, and it cannot tell a good week from a bad one. Do not gate a domain before it has on the order of 30–50 questions, and gate on the lower bound, never the point estimate. On a gated domain, run each question three times. A verdict that flips is unstable. Bootstrap at the question level, with a question's attempts kept together. Add a case when a new failure mode is confirmed, not because more data arrived. A mature set often lands at 100–200.
Default visibility is held_out. Never serve those questions, not in skills, not in verified examples, not in a query library. Lint for exact matches, near-duplicates, and, on high-risk cases, paraphrases. Gate on the held-out slice. Example-visible cases may still run. A large gap means stored questions pass and new ones do not. Keep a real held-out share per domain. Around a quarter is a solid start.
A case moves from draft to approved when the domain owner confirms the expected answer, and to retired when it should stop. Version every save. Re-check gold on a cadence. If the agent and the gold disagree, read the gold first, keep a golden-SQL error apart from an agent failure, and park the case as disputed until the owner decides.
This is the shape I store, for a neutral question. It is not one company's schema.
id: monthly_revenue_by_region_2026_10
domain: finance
question: "What was monthly revenue by region in October 2026?"
as_of: 2026-11-15
turns: []
expected_behaviour: answer # answer | ask | refuse
accepted_behaviours: [answer]
accepted_answers:
- metric: monthly_revenue
golden_sql: |
SELECT region, SUM(amount) AS revenue
FROM fact_orders
WHERE order_date BETWEEN '2026-10-01' AND '2026-10-31'
AND is_test_account = FALSE
GROUP BY region
approved_value: null # value of golden SQL when the owner approved it
unit: currency
tolerance_pct: 0.5
tolerance_abs: null # use an absolute tolerance for rates and ratios
expected_text: "" # for a reply with no single number
expected_refs:
metrics: [monthly_revenue]
datasets: [orders_monthly]
reports: []
expected_tools: [lookup_metric]
forbidden_tools: []
forbidden_tables: [raw_events]
required_checks: [number_backed, required_filter]
tags: [core, path]
family_id: null
risk_tier: high # high | medium | low
visibility: held_out # example | held_out
owner: "finance metrics owner"
status: approved # draft | approved | retired
schedule: "0 2 * * *" # 5-field cron in UTC, or empty for on demand
attempts: 3
source: {kind: production_trace, trace_id: "..."}
An approved answer case needs golden SQL, a stored value, or expected text. Pin "last month" or "last week" with as_of, and pass that date in as today. "Active users last week" uses the same shape.
The same example case, in text. Not a measured run.
| Field | Value |
|---|---|
| Question | What was monthly revenue by region in October 2026? |
| as_of | 2026-11-15, passed to the agent as today |
| Expected | An answer for monthly revenue by region, October 2026 only, test accounts excluded |
| Visibility | held_out |
| Risk | high |
| SQL | Pass |
| Answer | Fail |
| Explanation | Pass |
| First failing stage | report |
How should graders run: execution-match, then a rubric, then a person?
Run code and execution-match first, a rubric judge only where code cannot look, and a person for the cases code should not close.
On a production AI system I built for a growing company, I use this order anywhere a data agent can ship a number.
- Code checks first. They are cheap and reproducible. Grade the path and the answer, and name the first stage that failed: lookup, route, sql, execute, report, contract. A missing date filter fails at sql. The wrong number is the consequence.
- Execution-match for numbers. Run the owner's golden SQL at scoring time, on the same data, and compare result sets. Never compare SQL text, and never ask a model whether a number looks right. Compare the computed result with gold, and the headline with the computed result. A right reply on a wrong computation is luck. A wrong reply on a right computation is an output failure.
- An LLM-as-judge only where code cannot look. Answer, ask, or refuse. Whether the scope and the reading are stated. Whether an alternative is named. Whether the explanation matches the result. One judge per failure mode, on a different pinned model from the answering model. Validate it on the owner's labels, and aim above 0.9 true positive rate and true negative rate on a held-out split. Correct the pass rate with the Rogan–Gladen estimator, and report a bootstrap interval. Re-check fresh labels on a cadence. A prompt change or a grader-model change means a full re-validation.
- Human review for failures, disputed gold, and calibration. People approve the expected answers. They are not in the everyday loop.
The owner writes the golden SQL apart from the metric file, or a wrong definition passes its own test. Pin a closed period. Store approved_value. Flag golden_drift when scoring-time gold moves past the tolerance. That is a data event, not an agent fail. If more than one reading is defensible, give each its own golden SQL, and check that the alternative is named. For a breakdown, match on key columns, require the same key set, and apply the tolerance per cell.
Set tolerance per case. A relative 0.5% is a starting default for counts and currency. Rates need an absolute tolerance, in points or ratio units. Ranks and lists need the same key set. Order may differ.
number_backed is the check I will not skip. The headline has to appear in, or be derivable from, a tool result of that attempt. A number in none of them is invented. Hard block.
A first runner can stop at behaviour (answer, ask, or refuse), then result (execution-match or expected text), then route (the expected metric or source). If the golden SQL fails, bucket it as golden. If the runner breaks, bucket it as harness.
Put the query checks in code, and call that same code at answer time. Enforce a date or partition filter, no SELECT *, no summing a snapshot across a period, ratios of sums rather than averages of ratios, no fan-out joins, and an allow-list of tables. Each check rejects with a hint, warns in the footer, or turns into a question. One guided retry, then fail with the reason. Never a silent number. Also flag an empty result and a partial last period. Every trap needs that check, or a ticket to add one.
The same grader order, in text:
| Order | Who grades | What it decides |
|---|---|---|
| 1 | Code checks and execution-match | Result sets against golden SQL, and the first stage that failed |
| 2 | LLM-as-judge, one failure mode, on a different pinned model | Whether the agent answered, asked, or refused, and whether the explanation matches the result |
| 3 | Human review | Failures, disputed gold, and judge calibration. Not the everyday scoring loop |
Are public benchmarks your eval suite?
No. Public benchmarks are a reference for execution accuracy. They are not your stakeholders' questions, and they are not your definitions.
BIRD-SQL and Spider 2.0 are the public standard for execution accuracy: run both queries and compare results. Spider 2.0 follows Spider 1.0, the Yale Semantic Parsing and Text-to-SQL Challenge (Spider). A leaderboard score does not replace held-out questions the agent cannot look up. Chip Huyen's AI Engineering treats execution accuracy as this metric family, and sample size as part of whether a score means anything.
OpenAI's current pages are evaluation best practices and evaluating agent workflows. The OpenAI Evals API and dashboard shut down on 30 November 2026. OpenAI says so on Migrate from OpenAI Evals. The past-deprecations table on the deprecations page lists a 3 June 2026 notice and names Promptfoo as the replacement. I name Promptfoo because OpenAI lists it. I am not recommending it. Anthropic's define success criteria and build evaluations and Demystifying evals for AI agents say to grade the outcome and keep the trace. Google Cloud documents the Vertex AI Gen AI evaluation service. Those pages are not your questions.
When do you re-run after a knowledge or semantic layer change?
Re-run the touched domain, and every high-risk case, before you trust the agent again. Between those edits, run on the schedule below.
| Cadence | What runs | Purpose |
|---|---|---|
| Per-question schedule | A 5-field cron (hourly, daily, weekly, monthly, or empty) | Sanity checks, more often on a fragile source |
| Nightly | Every approved question, three attempts on gated domains | Trend with intervals. Data and model drift |
| Per release | The touched domain, or every high-risk case | The gate before production |
| Weekly | Live traces through the code checks, plus a short human review | Failure modes the set does not know yet |
A cron case is due when the latest fire time is later than its newest run and later than its approval, so a missed tick runs once. "Run now" is a manual trigger.
A wording-only skill or doc edit runs that domain's smoke set. A change to a metric, a required filter, routing, tool descriptions, or the answer contract runs the touched domains in full, plus every high-risk case. A change to the answering model or the grader runs the full suite, then you re-validate the judges.
Write the gate before you see the result: the metric, the scope, the threshold, the action, the owner.
Hard blockers. Any one stops the release: a regression case fails, a high-risk case returns a confident wrong number, number_backed fails, the lint finds a held-out case in served content, or a paraphrase family flips its number, source, or ask-versus-answer on a high-risk question.
Soft gates need a decision to proceed: the lower bound falls under the threshold, over-asking rises, or cost or bytes jump past what you agreed.
Noise inside run-to-run variation is not a regression. Store a system tuple every run: answering model, app version, grader model, prompt hash, content or commit id, skill versions, attempt count. Without it, a model change and a metric-file change look the same.
Report buckets, not one rate: by check and by first failing stage, then behaviour, result, route, golden, harness, unstable, disputed, unsafe versus safe, and example versus held-out. On a failed attempt, record the last stage that passed and the first that failed.
Use the same tools a person would, and withhold write and publish. Select traces by a dedicated eval caller and the attempt's time window, not by a session id that spans questions.
The same loop, in text:
| Step | What happens |
|---|---|
| 1 | A knowledge-layer or semantic-layer change lands |
| 2 | The suite for that change class runs |
| 3 | Failure buckets name what to fix |
| 4 | The suite runs again |
Where the definitions live is in What a Knowledge Layer for Data Agents Actually Needs. Changing that layer is one of the triggers above.
How do evals tie to the knowledge layer and the feedback loop?
A passing eval means the knowledge layer did its job: the right definition, the owner, and the why reached the agent. The feedback loop is how a confirmed miss becomes a new held-out case. I load those eval steps with four layers of exposure: L0 a one-line start every session, L1 a short index per topic, L2 one page per practice, L3 the full source, opened only to check a claim.
Examples and evals share material and must stay split. An example binds the real questions, owner-approved SQL, the asset it runs on, and the parameters it accepts. It can come from governed dataset SQL, an answer an owner marked verified, an eval question marked example, or mined history. History is raw material. Nothing is served until the owner approves it. An exact match runs the approved SQL. A near match shows a few examples. A near tie between meanings becomes a clarifying question. The system binds parameters. The model does not paste them into SQL. A nightly replay marks an example stale and pulls it from serving when the SQL, the metric fingerprint, or the result shape drifts. Never promote a held-out question into that library.
A "wrong" rating, a no-answer close, a search miss, or a code-check flag creates a candidate. Promotion needs an owner, and a passing eval when answers change. Wait for two independent signals, plus a random sample so the queue stays honest. Every confirmed miss becomes a held_out regression case, with two or three paraphrases, before anyone calls it fixed.
Send the failure to the right place. A wrong number the agent should have gotten becomes a regression eval. A recurring good question becomes a verified example. A missed word becomes an alias and a paraphrase eval. A missing definition becomes a metric change. Bad data becomes a dated known issue. A wrong route, with the content already right, becomes a code check or a tool description, then path evals. Skill prose is the last resort. One change per proposal, with a before-and-after eval on the cases it targets. Nothing is auto-promoted into a definition.
Some questions must ask before a query. Some must answer with no question. Over-asking fails too. Script the follow-ups, and do not let the harness contradict the agent's clarify rules.
A playbook you can point a session at is Data Analytics Skills. The skills are not the suite.
The same loop, in text:
| Step | What happens |
|---|---|
| 1 | A production signal creates a candidate |
| 2 | The owner triages it |
| 3 | It goes to an eval case, a verified example, or a metric fix |
| 4 | An eval confirms the change before anyone treats it as done |
What should you track over time?
Track the lower bound you gate on, where failures start, and what the suite costs. Do not track a single pass rate, and do not invent a score from one run.
- Pass rate per domain, with the interval and the lower bound you gate on.
- Pass rate per check, and per first failing stage.
- Attempts where the SQL was fine and the answer was not, and the reverse.
- The example versus held-out gap.
unstablerate,golden_driftcount, and disputed cases.- Retrieval alone: Recall@k and MRR against
expected_refs, where lookup is on the path. - Time from a confirmed production failure to a case in the suite.
- Spend by domain: agent tokens, judge calls, golden-query cost.
Schedule on risk, run code checks before judges, and run golden SQL once per question per run, not once per attempt. Do not cut the held-out set or the random review sample to save money.
What are three things to do tomorrow?
- Write down 20 real stakeholder questions, with the expected result or owner-approved SQL, taken from last week's tickets or chat. Mark each one
held_outuntil you have a leakage check. - Run them with execution-match on a pinned warehouse snapshot. Score SQL, the answer, and the explanation separately, and tag cases where the SQL was fine and the answer was not.
- Put the suite on a regression trigger: any change to the knowledge layer, the semantic layer, or a metric definition re-runs the touched domain, and every high-risk case, before you trust the agent again. Turn the first confirmed miss into a
regressioncase with two or three paraphrases.
If you want to talk through your eval suite, grab 30 minutes: https://calendar.app.google/P6mjrP2Akirk3zodA
Questions people ask
How do you evaluate a data agent?
A data agent is ready when it passes a fixed set of real stakeholder questions, not when the SQL runs. Score SQL correctness, answer correctness, and the explanation separately. Build a golden set from questions your team already asks, grade with execution-match first, and re-run the suite when the knowledge layer or the semantic layer changes.
Is valid SQL enough to trust a data agent?
No. A query can run and still use the wrong metric, source, filters, or grain. Score the SQL, the computed answer against trusted gold on the same data, and whether the explanation stays faithful to that result.
What is execution-match for a data agent?
Run owner-approved golden SQL at scoring time on the same data, and compare result sets. Do not compare SQL text, and do not ask a model whether a number looks right. Compare the computed result with the gold, and the headline with what was computed.
What belongs in a golden question set?
Questions people already asked, with an expected answer the domain owner approved. Tag each case, keep a held-out share the agent is never shown, and gate on that held-out slice rather than on a handful of smoke-test questions.
When should you re-run a data agent evaluation?
Re-run the touched domain, and every high-risk case, after a change to the knowledge layer, the semantic layer, or a metric definition. Also run on each case schedule, nightly for approved questions, and on a weekly sample of live traces.
