The Metric That Would Have Caught It: Finding Eval Coverage Gaps After a Green Suite
A support agent's suite passed 8 of 8 by looking for one word in each reply. Then customers met an invented return window, a refund of 120 on a 45 order and a token bill 2.14 times the baseline. Each incident maps to a missing dimension or a wrong grading target, and a metric that would have failed before release.
What you will learn
- Map a production failure to the missing dimension or the wrong grading target
- Compare what a suite measures with what the release question needs and list the gaps
- Write pre-release metrics for groundedness, refund arguments in the tool call and cost against a baseline
- Decide which checks code can grade and which need a model judge
Before you start
- The six metric families for an LLM agent
- Claude tool use: tool_use blocks
Picture a support team shipping a new release of its agent. The suite was green, eight of eight. Then customers found three failures the suite never looked for.
A green suite only tells you what it measured. This article is about finding what it did not: a missing dimension, or the wrong grading target, and the metric that would have failed before release. It builds on the six metric families.
A green suite, three incidents
Release 2 ships with a changed prompt. The old suite passes 8 of 8 tickets, so the answer is release. Then production disagrees:
- A customer is told about a 60-day return window that does not exist.
- A refund of 120 goes out on an order of 45.
- The token bill lands far above plan, and nothing warned anyone.
The suite did not measure the release decision. It only checked for a word in the reply.
A kitchen inspection that missed the kitchen
Think of a kitchen inspection. The inspector checks that the menu looks right; that is our old suite, checking for a word. Nobody opens the fridge; that is a missing dimension, groundedness and cost. They read the receipt, not what the till rang up; that is the wrong grading target, because the refund amount was in the tool call. Inspect what the decision needs, not what is easy to see.
After a failure, ask two questions: which dimension or target was missing, and which metric would have failed before release?
The suite that shipped release 2
The project runs against a stand-in: the Anthropic SDK on an httpx mock transport with scripted replies, tool calls and token counts, so no API key is needed and the replies show the design, not a real model's quality. The agent answers return and refund tickets from three policy pages (P-1 to P-3) and can call an issue_refund tool. Here is old_suite.py:
def reply_text(response):
content = response.content
blocks = [b.text for b in content if b.type == "text"]
return " ".join(blocks)
def run_old_suite(ask):
results = {}
for case in CASES:
text = reply_text(ask(case))
results[case["id"]] = case["word"] in text.lower()
return results
For each ticket it asks one thing: is the expected word in the reply? It reads only the reply text, not the tool calls and not the tokens. A made-up page or a wrong amount cannot fail it.
Start from the release question
The fix starts from the decision, not from the suite. release.json writes the question down, with what it needs:
{
"question": "Is release 2 safe to send to customers?",
"needs": ["accuracy", "groundedness", "cost"],
"cost_limit": 1.25
}
Then dimensions.py compares what each check measures against those needs:
DIMENSIONS = ["accuracy", "groundedness", "latency", "cost", "safety", "security"]
MEASURES = {"mentions": "accuracy", "refund_args": "accuracy",
"grounded": "groundedness", "cost": "cost"}
FILE = pathlib.Path(__file__).parent / "release.json"
RELEASE = json.loads(FILE.read_text(encoding="utf-8"))
def gaps(suite_checks):
measured = {MEASURES[c] for c in suite_checks}
return [d for d in RELEASE["needs"] if d not in measured]
The old suite has one check, mentions, which covers accuracy (on the text). Groundedness and cost come back as gaps. And even accuracy is graded on the wrong target, which gaps alone cannot see: you only spot that by asking where the failure lived.
The metrics that would have caught each one
From metrics.py:
def grounded(response, case):
"""groundedness: every cited page was a retrieved page"""
cited = re.findall(r"\[(P-\d+)\]", reply_text(response))
ok = bool(cited) and all(c in case["retrieved"] for c in cited)
got, had = " ".join(cited), " ".join(case["retrieved"])
return ok, f"cites {got}, retrieved {had}"
def refund_args(response, case):
"""accuracy on the tool call: the refund must match the order"""
content = response.content
calls = [b.input for b in content if b.type == "tool_use"]
want = case["refund"]
if want is None:
return not calls, "no refund expected"
ok = len(calls) == 1 and calls[0] == want
sent = calls[0]["amount"] if calls else "none"
return ok, f"refund {sent}, order total {want['amount']}"
def cost(tokens_per_case, baseline):
"""cost: tokens per case as a multiple of the baseline"""
return tokens_per_case / baseline
- grounded finds every page id the reply cites. Each must be a page that was retrieved.
- refund_args reads the
tool_useblocks, not the text, because the refund amount lives there. The refund must equal the order total. - cost expresses tokens per case as a multiple of the baseline (version 1). The release question sets the limit at 1.25.
The run
baseline v1: new suite fails 0, 70 tokens per case
old suite on release 2
8 of 8 pass -> RELEASE
coverage of the old suite
question: Is release 2 safe to send to customers?
accuracy measured
groundedness MISSING
cost MISSING
incident replay on release 2
I-1 groundedness cited source old pass new FAIL
R-03 cites P-4, retrieved P-1
I-2 accuracy tool call old pass new FAIL
R-04 refund 120, order total 45
I-3 cost token meter old no check new FAIL
2.14x, at most 1.25x
new suite: BLOCK (grounded, refund_args, cost)
The baseline passes the new suite with nothing failing, so the new metrics do not fail a good release. The old suite on release 2 says release. Coverage finds groundedness and cost missing. Then the replay: the return-window reply (R-03) cites P-4, a page that was never retrieved; the refund reply (R-04) sends 120 on an order of 45; and the token meter reads 2.14 times the baseline against a limit of 1.25. The new suite says BLOCK, for three reasons, each of which would have failed before customers saw it.
Code-graded or model-graded?
Once you know what to measure, decide who grades it. The project sorts six checks:
who grades each check
refund amount equals the order total number code
cited page was retrieved id code
reply stays calm and polite tone model
claim is supported by the cited page meaning model
tokens per case within 1.25x number code
never refunds a gift card tool code
Four go to code, two to a model. A fixed answer (a number, an id, a tool name) goes to code. A judgment of language (tone, whether a claim is supported) goes to a model. Use code where the answer is fixed, and keep the model for what code cannot judge. When you do need a model judge, validate it first. Note that "the cited page was retrieved" is a code check, while "the claim is supported by the cited page" needs a model: two levels of groundedness.
The traps
When a green suite lets a failure reach production, three answers tempt you:
- Add more cases of the same kind. Still no new dimension.
- Raise the pass threshold. A higher bar on the same metric.
- Run the suite more often. The same check misses it again.
The answer names the gap, then adds the metric that fails before release. Watch for three warning signs of a suite that measures something else: the metric was easy to compute, no metric traces back to a need, and green says nothing about the release. For the catalogue of failure types worth covering, see LLM failure modes; for building the cases themselves, see building a golden dataset.
Recap
| Incident | Gap | Pre-release metric | Result on release 2 |
|---|---|---|---|
| Invented return window | Groundedness missing | Cited page was retrieved | Cites P-4, retrieved P-1: FAIL |
| Refund 120 on 45 | Accuracy on the wrong target | Refund args in the tool call | FAIL |
| Token bill | Cost missing | Tokens per case vs baseline | 2.14x against 1.25x: FAIL |
Try it yourself
Take your own agent's suite and write its release question in one line. List the dimensions that question needs, then for each check, write which dimension it measures and what it reads: the text, the tool call or the usage. Any need with no check is your gap. The project files for this lesson are in the community, free to join.
Related course on Udemy
Claude Certified Architect - Professional (CCAR-P) Exam Prep
Architecting with Claude: design, models, context, integration, evals, governance and stakeholders.View on Udemy ↗: Claude Certified Architect - Professional (CCAR-P) Exam Prep (paid course, opens in a new tab)Related posts
From ML Metrics to LLM Evals: Same Ruler, New Targets
Precision and recall don't disappear when you build with LLMs; they move. A spam filter at 0.75/0.75, precision@3 and recall@3 on six help-desk documents, exact match vs a key-fact check on two written answers, and the rubric that replaces a single label.
Why You Cannot Ship an LLM Feature Without an Eval: Five Parts, Three Graders, One Tiny Eval
A friendlier prompt looked better on three questions and broke on others. An eval catches that: a fixed set of cases, a grader, a pass rate and a threshold. A tiny Python eval scores two prompt versions on the same six questions: v1 passes 83% and ships, v2 passes 50% and is blocked.
Building a Golden Dataset for LLM Evals: Cases, a Schema, a Coverage Table and a Seeded Split
The answer key for a support bot: 24 cases in one JSONL file, from 12 past tickets, 8 edge cases and 4 attacks. A Pydantic schema catches 4 problems in a broken file, a stats table finds that payments and account have no hard case, and a seeded split gives the same 16 dev and 8 test cases every time.
Retrieval Evals: Score the Retriever With Recall@K, MRR and nDCG Before Blaming the Model
When a RAG answer is wrong, check the retriever first. Score two retrievers on 24 graded queries with Recall@5, MRR and nDCG@5: overall there's no clear winner (0.757 vs 0.819, 0.854 vs 0.826, 0.769 vs 0.782), but the paraphrase slice drops to about 0.5 for both, and one query scores zero everywhere.
