How to measure an AI agent before it ships
Build a fixed eval harness: versioned questions, expected answers, an automated grader, and a run record. It takes a day, and it's the only thing that tells you whether a prompt change helped or hurt.
An eval harness is a fixed, versioned set of questions with expected answers, an automated grader, and a run record that stores every result against the commit, model version, and prompt version that produced it. Without one, a demo is your only evidence — and a demo is a sample size of three questions you wrote yourself.
The gap isn't model quality. A demo measures whether the agent can be right. Production cares about how often it is right, and what it does when it isn't.
A demo is a sample size of three
You wrote the demo questions. You know the catalogue, so you ask about things that exist. You know the prompt, so you phrase things the way it expects. Every question you reach for is drawn from the same distribution as the examples you built against.
Real users aren't drawn from that distribution. They ask about the product you discontinued, or mix two languages in one sentence, or paste an order number with a typo. Most of this isn't adversarial — it's just outside the handful of paths anyone thought to try.
So the first thing a harness gives you isn't a score. It's a question set you didn't choose.
What the harness needs
A useful harness is smaller than people expect. It has four parts.
A fixed question set, versioned in the repo. Not generated fresh each run — fixed, so a score this week is comparable to last week. Start at fifty questions. Pull from real logs the moment you have them; write them deliberately if you don't.
An expected answer, or an expected refusal. This is the part teams skip. Someone has to decide what correct looks like, including questions where the correct response is "I don't have that information." An agent that answers everything is just an agent whose failures you haven't found yet.
A grader. For factual lookups, use exact or fuzzy match against the source record. For prose, use an LLM judge with a rubric. Spot-check its verdicts against human judgment, and know the agreement rate before trusting the number. If the judge agrees with a human eight times in ten, the score carries roughly that much confidence — no more.
A run record. Every run writes its results with the commit hash, model version, prompt version, and date. The number alone is trivia. The number over time is what you actually manage.
run_id | commit | model | prompt_v | pass | fail | refused | hallucinated
---------|---------|--------------------|---------:|-----:|-----:|--------:|------------:
run_041 | a1b2c3 | gemini-2.5-flash | v7 | 44 | 3 | 3 | 2
run_040 | f9e8d7 | gemini-2.5-flash | v6 | 41 | 5 | 4 | 4
The rows above are illustrative, not a real run. The shape is the one we use for Nous, our agent engine that plans and acts via tools against real backend systems, before it touches live seller data for Iris, its first consumer. The hallucinated column is the number that matters at handover.
The one number worth publishing
If a retrieval-grounded agent produces an answer, it's in one of three states: grounded in a real source record, correctly declining, or asserting something not in the source data. That third state is the hallucination rate.
Of N questions in the eval set, the agent asserted a fact not present in the grounding data X times. Rate: X/N.
Two things make this honest rather than decorative. It counts assertions against source data — not vibes — which means you can only compute it if the agent's grounding is inspectable. And it's stated alongside N, because 2% over fifty questions and 2% over five thousand are not the same claim.
Equally important is the refusal rate. An agent can drive its hallucination rate to zero by declining everything. Reported together, the pair describes a real trade-off. Reported alone, either one is marketing.
Where questions come from before you have traffic
The objection to a fixed question set is always: "We don't know what users will ask yet." That's true, and it's not a reason to skip the harness — it's a reason to write the first fifty questions deliberately.
Four sources before launch:
The support inbox. If the process you're automating already exists in human form, you have real questions in real phrasing, for free.
The source data. Walk the catalogue, policy document, or schema. Write a question for each region, especially the thin regions where retrieval will fail first.
The boundary of scope. Write questions the agent should decline. This is the half of the set nobody writes, and it catches the worst failures.
Adversarial phrasing. Ask the same question badly — in two languages, with a typo in the identifier, or with a false assumption baked in.
Fifty questions written this way take an afternoon. The moment you have real logs, replace the invented ones with real ones. Keep the set at a fixed size, retiring questions the system has passed twenty times running in favour of ones it hasn't seen.
For EvidenceVault — our SOC 2 audit-evidence tool — the boundary-of-scope questions were the most productive. Its live analyzer maps 12 auditor requests to SOC 2 control criteria automatically, so the most dangerous failure is a confident mapping for a request outside that set. Write those out-of-scope questions first; an authoritative-looking wrong answer is worse than a refusal.
What to do about the grader you don't trust
Grading is where most harnesses quietly become theatre. Exact match works for a lookup with one right answer. Nothing else is that clean. The moment the agent produces prose, teams reach for an LLM judge and stop asking whether the judge is any good.
Hold the judge to the same standard you hold the agent. Take thirty graded examples, have a human grade them independently, compute the agreement rate. If the judge agrees with the human six times in ten, it's noise wearing a number.
The fix is a tighter rubric. Don't ask "is this answer good?" Ask "does this answer assert any fact not present in the supplied context — yes or no?" Narrow, binary, checkable questions produce judges that agree with humans. Broad qualitative ones don't.
Re-measure the agreement rate whenever you change the judge model. A grader is a dependency like any other, and it drifts.
JUDGE_PROMPT = """
You are an evaluation judge. Answer only YES or NO.
Does the answer below assert any fact NOT present in the provided context?
Context:
{context}
Answer:
{answer}
Output: YES or NO
""".strip()
Calibrating this prompt against 30 human-graded examples before trusting it in CI is a half-day task. Skip it and your reported hallucination rate is untethered from reality.
Reading the number over time
A single eval run tells you almost nothing. Its value is comparative. The first run establishes a baseline — usually worse than the team expected, which means the harness is working.
From then on, the run record turns a debate into an observation. Someone changes chunk size and the score moves three points: fact, not opinion. Someone swaps the reranker and the hallucination rate falls but the refusal rate doubles: a trade-off surfaced before a user found it.
Two patterns worth watching:
Climbing refusal rates alongside improving scores. The agent isn't getting better; it's getting more evasive.
Widening variance across reruns. The aggregate holds steady while per-run results drift. This usually means temperature or retrieval non-determinism has crept in — the same question now gets two different answers. Store per-question results, not just the aggregate. The aggregate tells you something moved. Only the per-question diff tells you what.
Why this survives the model you're using today
Providers deprecate models on their own schedule, with less notice than you'd like. When Heimdall — our self-hosted gateway that exposes Claude as an internal API with our own auth and rate limiting — needs to rotate its underlying model, the process should be: run the harness against the candidate model, read the per-question diff, adjust the prompt if needed, ship. With a harness that is an afternoon, not a fortnight of anecdotes.
The same applies to every other change that would otherwise be untestable: a new embedding model, a reranker, a prompt rewrite, a chunking strategy, a cheaper model for a subset of traffic. Each is a question about whether quality held. The harness is the only thing in the stack that can answer it.
The harness is roughly a day to build. It pays for itself the first time it stops a regression reaching production. It pays for itself again every time it replaces a week of manual re-testing with an afternoon.
For the diagnostic side — what to do once the harness tells you the agent is inventing things — we've written separately about why a RAG chatbot hallucinates. The harness is the first thing we build in an AI reliability evals engagement, and every build we ship includes one with a stated error rate agreed with the client before handover.