Domain 4 is where a Claude architecture stops being a prototype and becomes a system you can defend to a change board. At the professional tier the question is never "does the prompt work once" but "how do we know it still works after the next change, and what does each answer cost us in dollars and milliseconds." This domain asks you to treat non-deterministic model behavior with the same discipline software teams apply to any other dependency: measurable, regression-tested, and continuously observed.
The blueprint weight is 16%, and it spans four connected muscles: designing evaluations (golden datasets, task-specific metrics, offline versus online), judging quality at scale (LLM-as-judge and where humans still belong), keeping quality stable across changes (regression testing, A/B and canary rollout), and optimizing the two axes the business actually feels — cost and latency. Weak teams optimize one of these in isolation and regress another; the exam rewards architects who reason about the tradeoffs together.
Throughout, ground your answers in real Claude behavior: prompt caching changes the cost math, the Message Batches API trades latency for a 50% discount, and streaming changes perceived latency without changing total tokens. Verify specifics against docs.anthropic.com / docs.claude.com rather than trusting memory — the exam punishes fabricated numbers.
Designing evaluations: golden datasets and task-specific metrics
An evaluation is a repeatable measurement of whether the system does the job. It starts with a golden dataset: a curated, versioned set of representative inputs paired with expected outcomes or acceptance criteria. Quality of the eval is bounded by quality of this dataset, so it must cover the real distribution of traffic — including the messy, ambiguous, and adversarial cases — not just the happy path an engineer typed while building the feature.
Metrics must be task-specific. A classification task can use precision, recall, and F1 against labels. An extraction task can use exact-match or field-level accuracy. An open-ended generation task has no single right answer, so you define a rubric and score against it. Choosing the wrong metric — for example, exact-match on a summarization task — produces a number that looks rigorous but measures nothing useful.
| Task type | Appropriate metric | Anti-pattern to avoid |
|---|---|---|
| Classification / routing | Precision, recall, F1 vs labels | Reporting only overall accuracy on an imbalanced set |
| Structured extraction | Field-level / exact match, schema validity | Fuzzy human read-through of a few samples |
| Open-ended generation | Rubric score (human or LLM-judge) | Exact-match against one reference answer |
| Agentic / multi-step | Task success rate, step-level trajectory checks | Judging only the final message, ignoring the path |
Offline evals vs online / production evals
Offline evals run against your golden dataset in CI or a notebook, before shipping. They are fast, cheap, reproducible, and gate deployment. Online (production) evals measure the live system on real traffic: capturing outcomes, sampling for human or automated review, and watching business KPIs. Both are required — offline catches known-failure regressions, online catches the distribution shift and edge cases your dataset never anticipated.
- Offline: deterministic gate in CI, runs on every prompt/model change, blocks merge on regression.
- Online: samples live outputs, tracks real user outcomes, feeds new failure cases back into the golden dataset.
- Shadow / mirror: run a candidate on live traffic without serving its output, to compare before exposing users.
- The golden dataset is a living asset — production failures should be triaged and promoted into it so the same bug never regresses twice.
LLM-as-judge: rubrics, bias, and calibration
For open-ended output, human grading is the gold standard but does not scale. Using Claude to grade Claude's output — LLM-as-judge — scales to thousands of samples cheaply. It works only if you engineer it deliberately: give the judge a precise rubric with explicit criteria and a defined scale, ask for a short rationale before the score (reasoning improves reliability), and where possible provide a reference answer. A vague "rate this 1-10" produces noisy, non-reproducible scores.
Judges carry known biases you must control for: position bias (favoring the first option in a pairwise comparison — mitigate by swapping order and averaging), verbosity bias (rewarding longer answers), and self-preference. Calibration is the safeguard: periodically compare judge scores against a human-labeled sample and measure agreement. If the judge disagrees with humans, fix the rubric before trusting the judge at scale.
| Bias / risk | How it shows up | Mitigation |
|---|---|---|
| Position bias | Prefers whichever answer is shown first | Randomize/swap order, average both directions |
| Verbosity bias | Longer answer scored higher regardless of quality | Rubric penalizes padding; control for length |
| Self-preference | Favors outputs in its own style | Calibrate against human labels; use a strong judge model |
| Uncalibrated scale | Scores drift, not comparable across runs | Anchored rubric with examples per score level |
Regression testing prompts and agents; structured error metadata
Prompts and agent definitions are code and deserve version control, tests, and CI. A regression test suite runs the golden dataset against a candidate prompt/model and fails the build if quality drops below a threshold. Because model output is non-deterministic, thresholds are statistical (for example, pass rate must stay above 95%) rather than exact-match on every row. Pin the model version in tests so an unrelated model update does not silently move your baseline.
Every failure should emit structured error metadata rather than a free-text log line. Capturing the input, the output, an error category, the model/prompt version, latency, and token counts turns a pile of anecdotes into a queryable dataset. That metadata is what lets you say "tool-argument errors rose 12% after the v7 prompt" instead of "it feels worse" — and it is the raw material for the next round of improvement.
# Structured error record captured on every eval/production failure
error = {
"trace_id": trace_id,
"prompt_version": "checkout-v7",
"model": "claude-<pinned-version>",
"input": user_input,
"output": model_output,
"error_category": "tool_arg_invalid", # controlled vocabulary, not free text
"expected": golden_expected,
"latency_ms": 1840,
"input_tokens": 3120,
"output_tokens": 210,
}
# Aggregate by error_category + prompt_version to prioritize the next fix.Cost and token optimization: caching, routing, and Batches
Cost is driven by tokens and by which model tier processes them. Four levers matter most at the architecture level. First, prompt caching: mark large stable prefixes (system prompt, tool definitions, long documents) as cacheable so repeat requests reuse them. Cache reads are billed at a large discount versus base input tokens, while a cache write carries a modest premium — so caching pays off when the same prefix is reused many times within the cache lifetime. Second, model routing: send easy, high-volume requests to a cheaper, faster tier (Haiku-class) and reserve the most capable tier for genuinely hard work, optionally using a cheap classifier to route.
Third, the Message Batches API: for work that does not need an immediate answer — bulk evals, offline enrichment, backfills — submit requests as a batch for a 50% discount on input and output tokens, with results returned within 24 hours. Batches support the same features as standard calls, including tool use. Fourth, trim what you send and store: prune stale conversation history, summarize long context, and cap verbose tool output before it re-enters the prompt, since every token you carry forward is billed on every subsequent turn.
| Lever | What it does | Best when |
|---|---|---|
| Prompt caching | Reuses a stable prefix at a large read discount | Same system prompt / docs / tools reused frequently |
| Model routing | Cheaper tier for easy tasks | High volume with a mix of easy and hard requests |
| Message Batches | 50% off, results within 24h | Latency-insensitive bulk work (evals, backfills); supports tool use |
| Context trimming | Fewer tokens carried per turn | Long conversations or bloated tool outputs |
Latency optimization: streaming, parallelism, caching
Latency has two flavors: total time to complete a response and time-to-first-token (perceived latency). Streaming does not reduce total tokens or total time, but it starts delivering output immediately, so users perceive the system as far faster — essential for any interactive UI. For independent sub-tasks (fanning out over many documents, calling several tools that do not depend on each other), issue requests in parallel rather than serially so wall-clock time is bounded by the slowest call, not the sum.
Prompt caching also cuts latency, not just cost, because cached prefixes skip re-processing. Model routing helps here too: smaller models return faster. And the biggest structural lever is often shrinking the work — fewer tokens in and out, fewer sequential agent steps, and capping generation length all reduce time directly. Optimize the tail (p95/p99) that users actually feel, not just the average.
- Streaming: improves time-to-first-token and perceived speed; total generation time is unchanged.
- Parallelism: run independent model/tool calls concurrently to bound wall-clock time by the slowest.
- Prompt caching: cached prefixes cut both latency and cost on repeated large context.
- Cheaper/smaller model tier: faster responses for tasks that do not need the top tier.
- Trim output: cap max_tokens and avoid needlessly verbose formats to shorten generation.
Measuring reliability; A/B and canary evaluation
Reliability is measured, not asserted. Track task success rate, error rate by category, and consistency across repeated runs of the same input (non-determinism means a single pass is not proof). For agents, measure at the trajectory level — did each step take a sensible action — not only whether the final message looked plausible. Set explicit reliability SLOs and alert when they degrade.
When you change a prompt, model, or agent, roll it out safely. A canary sends a small percentage of live traffic to the new version while the online evals watch its metrics; if quality or cost regresses, roll back before most users are affected. An A/B test splits traffic between two versions and compares outcomes with enough volume to reach statistical significance. Both are the production-side complement to offline regression tests: offline proves the candidate does not regress known cases, canary/A-B proves it holds up on real traffic.
| Technique | Traffic exposed | Primary purpose |
|---|---|---|
| Offline regression suite | None (pre-deploy) | Gate merge on known-case quality |
| Shadow / mirror | 0% served (runs in parallel) | Compare candidate on live inputs safely |
| Canary | Small % (e.g. 1-5%) | Catch regressions early, roll back fast |
| A/B test | Split (e.g. 50/50) | Statistically compare two versions on real outcomes |
Key takeaways
- 01A golden dataset plus task-specific metrics is the foundation — build the measuring stick before optimizing anything.
- 02Run both offline evals (deterministic CI gate) and online evals (real traffic), and feed production failures back into the golden set.
- 03LLM-as-judge scales grading but is an instrument, not ground truth: use anchored rubrics, control for position/verbosity bias, and calibrate against human labels.
- 04Treat prompts and agents as code: version them, regression-test with statistical thresholds, and pin the model version so baselines don't drift.
- 05Capture structured error metadata with a controlled category vocabulary so failures become a queryable, improvement-driving dataset.
- 06Cut cost with prompt caching (discounted reads on stable prefixes), model routing to cheaper tiers, Message Batches (50% off, within 24h, supports tool use), and context trimming.
- 07Cut latency with streaming (perceived speed), parallelism for independent calls, caching, smaller models, and shorter output — optimize p95/p99, not just the average.
- 08Roll out changes safely: offline regression gate, then canary or A/B on live traffic with automated rollback.
Common mistakes
Optimizing prompts by eyeballing a few outputs instead of measuring against a fixed golden dataset.
Build a versioned golden dataset with task-appropriate metrics and score every change against it so you can distinguish improvement from regression.
Trusting LLM-as-judge scores without calibrating them against human labels.
Periodically compare judge output to a human-labeled sample, measure agreement, and fix the rubric before relying on the judge at scale; control for position and verbosity bias.
Assuming streaming makes the system faster overall.
Streaming only improves time-to-first-token and perceived latency; total tokens and total time are unchanged. For real throughput gains, trim tokens, parallelize, cache, or use a smaller model.
Using the Message Batches API for latency-sensitive, interactive requests.
Batches trade latency for a 50% discount with results within 24 hours — use them only for latency-insensitive bulk work like offline evals and backfills, where they still support tool use.
Logging failures as free-text and trying to categorize them later.
Capture structured error metadata with a controlled category vocabulary, model/prompt version, and token/latency fields at the moment of failure, so you can aggregate and prioritize fixes.
Frequently asked
When should I use LLM-as-judge versus human review?
Use LLM-as-judge to scale grading of open-ended output across large volumes cheaply, once you have calibrated it against human labels with an anchored rubric. Keep humans in the loop for the calibration sample, for high-stakes or safety-critical decisions, and for ambiguous cases the judge disagrees on. The judge scales measurement; humans keep it honest.
Does prompt caching always save money?
No. A cache write costs a modest premium over normal input tokens, while cache reads are heavily discounted, so caching pays off only when the same byte-stable prefix is reused enough times within the cache lifetime to amortize the write. Put stable content (system prompt, tools, reference docs) first and volatile content last; verify current pricing and TTL on docs.anthropic.com.
How do offline and online evals differ, and do I need both?
Offline evals run against a fixed golden dataset in CI to gate deployment — fast, reproducible, and good at catching known regressions. Online evals measure the live system on real traffic and catch distribution shift and edge cases your dataset missed. You need both, and production failures should be promoted into the golden dataset so the same bug never regresses twice.
What's the difference between a canary and an A/B test?
A canary routes a small slice of live traffic (say 1-5%) to a new version while online evals watch for regression, enabling fast rollback before most users are affected — it's primarily a safety mechanism. An A/B test splits traffic (often 50/50) to statistically compare two versions' outcomes and decide which is better. Canary asks 'is this safe to ship'; A/B asks 'which one is better'.
How do I handle non-determinism when regression-testing prompts?
Use statistical thresholds rather than exact-match on every row — for example, require pass rate to stay above a set bar across the golden dataset, and run repeated samples on key inputs to measure consistency. Pin the model version in tests so an unrelated model update doesn't move your baseline, and treat threshold breaches as build failures.
Independent, unofficial study material. Not affiliated with, endorsed by, or authorized by Anthropic. Every example is original and written to teach the public exam objectives — no real exam questions are reproduced. Technical details reflect Claude, the Anthropic API, Claude Code, and MCP as of July 25, 2026; always confirm specifics against current official documentation.
Test yourself
Turn what you just read into answers you can check.