🎓 Claude Certification Prep

Home › CCDV-F › M04

Eval, Testing, and Debugging

Domain 4 10% of exam 48 practice questions ~16 min read

Design evals that measure the stated quality goal (golden sets, regression tests, behavioral checks, LLM-as-judge calibrated against human labels, defensible metrics), and read traces to diagnose failure modes, separate integration-layer defects from model-output errors, and fix the cause.

Skills measured in this domain:
  • Evaluation Design: LLM-as-judge calibrated against human labels, golden sets, regression tests, behavioral checks, metrics
  • Failure-Mode Diagnosis from traces: hallucination, refusal, under-acting, context loss, format drift; integration layer vs model output

Domain overview

Domain 4 accounts for 10% (about 6 scored items). Two skills: (1) Evaluation Design — building an eval that measures the stated quality goal and choosing defensible graders and metrics; (2) Failure-Mode Diagnosis — reading a trace (a record of the steps) or a reproduction, naming the failure mode, determining whether the defect lies in the integration layer (code, harness, configuration) or in model output, then choosing a recovery that addresses the cause rather than the symptom. Items often show a log, a JSON response, or a score table and ask for "the best next step". Typical distractors: "switch to a stronger model", "retry", "increase max_tokens", "add IMPORTANT to the prompt" — they sound reasonable but don't touch the cause.

Eval design: what to measure

From goal to criteria

An eval consists of a task (input and success criteria), trials (individual runs; you need several because output is non-deterministic), a grader (the scoring logic), the transcript/trace (all output, tool calls, intermediate results), and the outcome (the final state of the environment). An agent saying "I booked the ticket" is not an outcome; the outcome is the booking record in the database. Grade the outcome, not the self-report.

Start from the cost of a wrong answer, not from the model's price. Meridian example: each wrong answer costs about 5 minutes of manual checking, and the team can tolerate 5 per 50 reports, i.e. 10%, so the accuracy floor is 90%. If a wrong answer costs $1,000 because it reaches the customer, the floor rises to 100%. Run every model on the same cases and the same prompt so the model is the only variable; among the models that clear the floor, choose the one with the lowest cost per completed task (cost of one run ÷ number of correct answers).

Golden sets and case design

  • Golden set (reference labels, e.g. golden.json): each case has an id, a category, and the expected answer for each field. Write the answers before running any model so the model's results don't steer you.
  • Volume over polish: 20–50 simple cases drawn from real failures are a good start. The prompt evaluation course suggests a long-term target of at least 100 test case/golden answer pairs.
  • Stratify edge cases by their share of production: if scanned reports make up 5% of traffic, they should be about 5% of the cases. The case set must look like production.
  • Unambiguous tasks: two experts reading independently must reach the same pass/fail verdict; each task has a reference solution proving it can be solved. A 0% pass rate after many attempts usually signals a broken task, not a weak model.
  • Balanced sets for behavior: include cases where the model should act and cases where it should not (e.g. it should search the web for a weather question, and should not for stable knowledge). Testing only one side skews optimization toward overtriggering or undertriggering.
  • A clean environment for every trial: leftover state (files, cache, git history) causes correlated failures or opens shortcuts for cheating.

Key point

The order for a minimal eval: (1) set the accuracy floor from the cost of a wrong answer, (2) write the answers before running a model, (3) build a production-like case set, (4) use code graders for every field that can be checked exactly, (5) a judge with a rubric, a schema, and an unknown option, (6) hand-grade a sample before trusting the judge.

Choosing a grader

Grader type Examples Strengths Weaknesses Use when
Code-graded exact match, regex, keyword, test pass/fail, static analysis, tool-call checks, final-state checks Fast, cheap, objective, reproducible Brittle with valid variations Every field that can be checked exactly: format, valid JSON, numbers, tests
Model-graded (LLM-as-judge) rubric, NL assertions, pairwise, comparison with a reference, multiple judges Flexible, can grade free text, scales Non-deterministic, more expensive, must be calibrated Tone, helpfulness, instruction following
Human-graded SME, spot checks, A/B, inter-annotator agreement Gold standard Slow, expensive High-risk decisions; calibrating judges

Principle: use code for every field that code can check exactly, and use a judge only for what code can't handle. Graders can be combined as weighted, binary (every grader must pass), or hybrid. Grade the outcome rather than forcing a specific path: agents often find valid approaches the eval author never thought of. Multi-part tasks should award partial credit.

Exam trap

"Use LLM-as-judge for everything because it's flexible" is wrong. Checking for valid JSON, matching numbers, and passing tests must be done in code: faster, cheaper, deterministic. Conversely, a regex that looks for phrases like "I'm sorry" to grade refusals is brittle: it misses other phrasings.

LLM-as-judge and calibration against human labels

A defensible judge needs:

<rubric>The answer is correct when the risk is quoted verbatim from the report.
If the report does not state a risk, the correct answer is null.</rubric>
<answer>{model_output}</answer>
Return JSON: {"explanation": "...", "verdict": "correct" | "incorrect" | "unknown"}
  • A clear rubric inside XML tags; a schema that restricts the verdict to a fixed set of values (structured output); an unknown escape hatch so the judge doesn't have to guess when information is missing. Require an explanation so you can read why the judge decided as it did.
  • One judge per dimension: grade each criterion with its own judge instead of a single prompt that grades everything. On a 1–10 scale, ask for strengths, weaknesses, and reasoning before the score so the judge doesn't default to around 6.
  • Calibration: first run the judge on cases that code can grade, so you have verified answers. Then hand-grade a sample and compare it with the judge's verdicts; where they disagree, clarify the rubric and rerun. The judge must show high agreement with experts; measure it as an agreement rate or as precision/recall/F1 against human labels.
  • Use a different model from the one that generated the output, and pin the judge model across runs (e.g. the cookbook fixes GRADER_MODEL) so score changes reflect the system, not the judge.
  • Grade the right part: if the prompt asks for quotes first and then the answer in a tag, parse the content inside <result> (or after </source>) instead of passing the whole response to the grader.

Scenario example

A team uses Claude to grade the "empathy" of customer support answers; the judge's score rises from 7.1 to 8.4 after a prompt change, but CSAT doesn't move. The right step: sample about 50 answers, have CS specialists hand-grade them with the same rubric, and measure their agreement with the judge; fix the rubric where they diverge before trusting the score trend. "Switch to a stronger judge" or "grade more answers" still doesn't answer whether the judge measures what users actually perceive.

Defensible metrics

Metric Meaning Use when
pass@k Probability that at least one of k attempts succeeds You need just one correct solution (generate several proposals, a human picks)
pass^k Probability that all k attempts succeed Customer-facing agents that must be consistent every time: 75% per attempt → pass^3 ≈ 42%
Accuracy against the floor Share of correct cases Model selection, release gating
Precision / Recall / F1 False positives and misses Classification, detection, evaluating judges
Cost per completed task, latency, number of tool calls Efficiency Comparing configurations that reach the same quality
  • A capability eval starts with a low pass rate — a "hill to climb". A regression eval must stay near 100%; once a capability eval scores high, it graduates into a regression eval. An eval at 100% is saturated and only useful for catching regressions.
  • Read results by field and by case type, not just the overall score: 84% overall can hide 50% in the "missing risk" group.
  • Run each configuration at least twice, because the same case can produce different results from run to run.
  • Infrastructure noise (resources, infra errors) can shift agentic benchmark scores by several percentage points; small leaderboard gaps (under about 3 points) deserve skepticism before you draw conclusions.

Exam trap

A score jump doesn't necessarily mean the model got better. Read the transcripts: the grader may have been penalizing correct solutions (CORE-Bench went from 42% to 95% after grading bugs such as 96.12 vs 96.124991… were fixed), or the agent found a shortcut past the grader. Graders must be hard to game, and every score change should be confirmed by reading transcripts.

Regression and evals in CI/production

  1. Smoke eval on every PR: a subset (e.g. 10 of 50 cases) with a threshold (Meridian uses 88%), set as a required check through branch protection so a failing PR can't be merged.
  2. CI for agent configuration changes: run the suite whenever CLAUDE.md, .claude/**, or evals/** change, and nightly. Don't use --bare, because it skips the very CLAUDE.md and skills under test; check is_error in the JSON result. Each task checks outcomes: tests pass, lint is clean, no test lines deleted, policy scripts, behavior tests; an allowlist of files that may be edited blocks "edit the tests to make them green".
  3. Full suite through the Batch API: 50% cheaper, each request has a custom_id, track request_counts, batches expire after 24 hours.
  4. Production monitoring: every night, sample 1–5% of real traffic for the judge to grade; alert when the score falls more than two standard deviations below the rolling baseline. Every failure found becomes a new case in the suite; every incident becomes an eval.
  5. Swiss cheese: automated evals, production monitoring, A/B tests, user feedback, transcript review, and human studies — each layer catches what the others miss. A postmortem of three infrastructure incidents showed that noisy evals can let real degradation slip through; evals need to be more sensitive.

Key point

Iterate on the prompt before upgrading the model: read failures by case group and by field, fix the prompt, rerun. When the score stops improving but is still below the floor, the model lacks the capability, and only then should you upgrade the model. Every prompt or case change requires rerunning the eval, because the right model may change too.

Diagnosing failure modes from traces

Failure mode Signs in the trace Common cause Fix for the cause
Hallucination Answers fields that aren't in the source; citations don't match The prompt doesn't allow "I don't know"; missing grounding Allow null/"I don't know", quote first then answer, cite-and-retract, a verification pass, restrict outside knowledge
Refusal "stop_reason": "refusal" with HTTP 200; or the model asks to confirm instructions placed inside a tool_result Content blocked by safeguards; your instructions are in the wrong place Handle the refusal branch, don't retry the same prompt; move instructions out of tool_result
Under-acting Reports "done" without running tests; few tool calls; stops early A "minimize tool calls" prompt followed too literally; low effort; no completion criteria Clear completion criteria, a verification step, feature list + progress file for long tasks
Overtriggering Calls tools/skills even when they aren't needed Legacy CRITICAL/MUST language Tone down the instructions
Context loss Repeats work already done, forgets decisions, picks odd tools The harness truncates history/thinking; compaction drops the original question Fix the harness; compaction instructions that preserve the goal
Format drift A preamble before the JSON; "foo\n" breaks string matching Verbal instructions only; code matches raw strings Structured output/strict: true; parse with json.loads() instead of comparing strings
Inconsistent output Same input, different results across runs Non-determinism, ambiguous prompt Measure pass^k, run multiple trials, best-of-N consistency checks, tighten the rubric/prompt

Integration layer or model output?

The first question when reading a trace: did the model receive what we think it received? Many "model errors" are actually integration-layer defects:

{"stop_reason": "max_tokens", "content": [{"type": "text", "text": "{\"items\": [{\"id\": 1, ..."}]}

The truncated JSON here is not format drift by the model; the output hit its limit. Code that handles only end_turn/tool_use will fail to parse it and may retry pointlessly. Distinguish max_tokens (hit the output limit: raise max_tokens or stream) from model_context_window_exceeded (ran out of context window: compact or split the conversation).

Integration-layer signs: - The request error tool_use ids were found without tool_result blocks immediately after: the harness omitted the tool_result for a tool_use or didn't make it the first block of the user message. - The model calls tools sequentially even though they could run in parallel: the harness sends each tool_result in a separate turn instead of grouping them into one user message. - String matching on tool input suddenly breaks after a model change: the new model keeps a trailing newline or escapes JSON differently — normalize and parse instead of comparing raw strings. - Calls tool A instead of B: vague descriptions — distinguish tools by when to use them, not just what they do. Invents parameters that aren't in the schema: turn on strict: true. When a tool fails, return a tool_result with is_error so the model can correct itself. - Claude Code postmortem (Apr 23): a bug that cleared old thinking on every turn instead of once made Claude "forgetful", repetitive, and prone to odd tool choices — symptoms that look like a weak model, but the cause was in the harness. A system prompt change meant to reduce verbosity cut code quality by 3% and was caught only through ablation (removing prompt lines one at a time to measure their impact). - Lower agent scores on third-party platforms usually come from a different harness configuration, not from the model.

Exam trap

When a trace shows the agent forgetting work, repeating itself, or making things up, "switch to a stronger model" is a very tempting option. First compare the actual payload sent to the API with what you think the model receives: a missing tool_result, a tool error swallowed into an empty string, or truncated history or thinking all make the model "look weak" even though the defect is in the harness.

Scenario example

An order-lookup agent answers "Order #8812 was delivered on Mar 12," but the trace shows that get_order returned {"error": "timeout"} and the code passed an empty string as the tool_result. The model "hallucinated" because the harness swallowed the error. Root fix: return a tool_result with is_error: true and a clear message, and allow the model to answer "the data couldn't be retrieved". Adding "don't make things up" to the system prompt only treats the symptom.

Fix the cause, not the symptom

Symptom Treating the symptom (trap) Fixing the cause
Truncated JSON Retry, raise max_tokens without checking Check stop_reason and handle each branch; structured output
Persistent refusals Retry many times Read stop_reason, surface it to the user, change the content or the flow
Agent reports done too early "Do not be lazy" Completion criteria + verification step + Stop hook/tests
Tools run unnecessarily Add new guardrails Tone down CRITICAL/MUST language
Eval score drops 2 points overnight Roll back immediately Check for noise (rerun, compare with the rolling baseline), read transcripts, then conclude

Key point

Diagnostic workflow: reproduce → read the trace (the actual input the model received, stop_reason, tool calls/results) → name the failure mode → identify the layer (integration or model) → fix the cause → add the case to the regression suite so the defect doesn't come back.

Exam tip

"Retry" is right for transient errors (rate limits, network timeouts) and wrong for deterministic stop conditions (refusal, max_tokens, wrong schema). "Switch to a larger model" is almost always wrong when the trace points to a harness defect or a prompt that hasn't been iterated on.

Quick summary

  • Set the accuracy floor from the cost of a wrong answer; among the models that clear the floor, choose the cheapest by cost per completed task.
  • Write the golden answers before running any model; 20–50 cases from real failures, stratified by production share.
  • A good task: two experts reach the same verdict, and it has a reference solution; 0% after many attempts usually means a broken task.
  • Balanced should/shouldn't sets to avoid overtriggering and undertriggering.
  • Code graders for every field that can be checked exactly; judges for free text; humans for high-risk decisions and calibration.
  • Judges: rubric, schema, unknown escape hatch, one judge per dimension, a different model from the generator, a pinned judge model.
  • Calibrating a judge: run it on code-gradable cases, hand-grade a sample, measure agreement, fix the rubric.
  • pass@k = at least one success; pass^k = every attempt succeeds (75% → pass^3 ≈ 42%).
  • Capability evals graduate into regression evals; an eval at 100% is saturated.
  • Smoke eval as a required check on PRs; full suite through the Batch API; a nightly 1–5% traffic sample, alerting at more than two standard deviations below baseline.
  • stop_reason: "refusal" → don't retry the same prompt; max_tokens is not the same as model_context_window_exceeded.
  • A missing tool_result, or a tool_result that isn't first → integration defect; parse JSON instead of comparing raw strings.
  • Overtriggering → tone down the instructions; under-acting → completion criteria and a verification step.
  • Iterate on the prompt before upgrading the model; every production failure becomes a regression case.