Production8 min read

LLM evaluation harness: golden sets, CI gates and online evals

An LLM evaluation harness for a product is a test system with three parts: a versioned golden set of real cases, a CI gate that blocks a change when specific cases stop passing, and online scoring of live traffic that feeds new failures back into the golden set. The scorers are the easy part. What separates a harness you can trust from a dashboard you ignore is how it handles noise: repeated trials, per-case comparison against a baseline, and error bars on every pass rate.

Most guides cover the vocabulary and stop. This one covers the decisions a staff engineer will push you on, with a gate you can drop into CI.

Two things called an LLM evaluation harness

Search for the term and the first result is EleutherAI's lm-evaluation-harness, a framework that runs language models against dozens of academic benchmarks with public prompts so results are comparable between papers. It is the right tool for choosing or fine-tuning a model. It is the wrong tool for asking whether your support bot still refuses to leak a customer's address after Tuesday's prompt change.

Model benchmark harness Application eval harness
Question it answers Which model is more capable? Did my system regress?
Unit under test The model Prompt, retrieval, tools, model, code together
Dataset Public academic tasks Your own cases, mostly from production
When it runs At model selection On every change that shapes output
Main risk Benchmark contamination A golden set that drifts from real traffic

Everything below is about the second column. Anthropic's agent-evals guide uses the same split in different words: capability evals start at a low pass rate and measure progress, while regression evals should sit near 100% and exist to catch breakage. A good capability case graduates into the regression suite once the system reliably passes it.

The architecture: three loops, one set of scorers

no new failures

new failures

Change: prompt, model, retrieval, tool or code

PR gate: smoke subset, 3 trials per case

Per-case diff against main baseline

Merge

Block and post the failing cases on the PR

Nightly: full suite, more trials, judge scorers

Production: sample traffic, score asynchronously

Triage low scores and user complaints

Add the case to the golden set with a label

The pre-merge loop catches regressions you can name. The production loop catches the ones you couldn't name yet. The learning loop is the arrow from triage back into the golden set, and it is the reason the harness gets better instead of staler.

The rule that keeps the three loops honest: one scorer implementation, used everywhere. If CI calls a JSON-schema check and a rubric judge, production scoring calls the same functions with the same versions. Otherwise "good" means two different things and the two loops will argue.

Build the golden set from failures, not imagination

Anthropic's guide suggests starting with 20 to 50 simple tasks drawn from real failures, because early in a product the effects you are looking for are large. A small set you keep labeled beats a big one nobody maintains.

What goes in each case matters more than the count:

  • Input and context. The exact prompt inputs, retrieved documents and tool responses, recorded so the case replays without live dependencies.
  • A checkable expectation. A reference answer, a required field, a forbidden behavior or a rubric. Two domain experts should independently agree on pass or fail; if they can't, the case is ambiguous, not hard.
  • Both directions. Cases where a behavior should happen and cases where it shouldn't. A set that only tests refusals teaches the system to refuse everything.
  • Tags. Intent, difficulty, locale, failure mode. You will slice by these when an aggregate looks fine and a segment is broken.

Real traces need redaction before they become fixtures. Golden sets live in repos and CI logs, so treat them as data with a retention policy.

When I measured Whisper fine-tuning for Fluently Flow, the golden set was ground-truth transcripts and the scorer was word error rate, which went from about 23% to 9%. ASR made that easy because the reference is unambiguous. Most LLM features don't have a single right answer, which is why the scorer layer needs more care.

Order scorers from cheapest to most uncertain

Anthropic's documentation ranks grading methods clearly: code-based grading is the fastest and most reliable, human grading is the most flexible and the most expensive, and model-based grading sits between them but must be checked for reliability before you scale it.

Scorer Use it for Cost per case Where it can block
Deterministic code Schema, required fields, forbidden strings, tool-call arguments, length, latency Near zero PR gate from day one
LLM judge Faithfulness, tone, whether an answer follows a rubric One model call Nightly first; PR gate once its agreement with humans holds
Human review Calibrating the judge, high-stakes releases Minutes of an expert Release sign-off

Run them in that order and short-circuit: if the output fails the schema, don't pay for a judge call. Trading Guard's Research Lab is layered the same way, with deterministic rule checks and labeled examples underneath an LLM-as-a-judge comparison against the trader's rulebook, plus blind historical replay. The judge is one layer of evidence, never the whole verdict.

Langfuse's guide gives a sensible promotion path for judges: run a judge metric as a warning until its baseline is stable, then make it blocking. I'd add a written agreement target against human labels before the switch, re-measured whenever the judge model, the judged model or the rubric changes.

The regression gate: compare cases, not averages

Here is where most harnesses go wrong. A typical gate computes an average score and fails below a threshold. Two problems follow.

First, an average can rise while a case that used to pass now fails. A prompt change that fixes five easy cases and breaks your most important refusal case looks like an improvement. Compare each case against its result on main.

Second, LLM output is non-deterministic, so a single run per case turns flakiness into false alarms. Run each case a few times and require it to pass every trial. Anthropic's guide calls this pass^k: with a 90% per-trial success rate, the chance of passing three trials in a row is 0.9 cubed, about 73%. That is the number your users experience when they retry.

from dataclasses import dataclass
from math import sqrt

@dataclass
class CaseResult:
    case_id: str
    trials: list[bool]  # one entry per trial, True = every scorer passed

    @property
    def passed(self) -> bool:
        return all(self.trials)  # pass^k, not pass@k

def wilson(k: int, n: int, z: float = 1.96) -> tuple[float, float]:
    """95% interval for a pass rate of k out of n."""
    p, d = k / n, 1 + z * z / n
    centre = (p + z * z / (2 * n)) / d
    half = z * sqrt(p * (1 - p) / n + z * z / (4 * n * n)) / d
    return round(centre - half, 3), round(centre + half, 3)

def gate(baseline: dict[str, bool], run: list[CaseResult]) -> list[str]:
    """Return the cases that passed on main and fail now. Empty means merge."""
    return [r.case_id for r in run if baseline.get(r.case_id) and not r.passed]

run = [CaseResult("refund-policy", [True, True, True]),
       CaseResult("no-pii-echo", [True, False, True])]
newly_failing = gate({"refund-policy": True, "no-pii-echo": True}, run)
k = sum(r.passed for r in run)
print(newly_failing, wilson(k, len(run)))

The gate blocks on a concrete list of case IDs, which is also what the PR comment shows. Reviewers fix a named failure; nobody can fix "score dropped to 0.84".

Put error bars on every pass rate

Small golden sets are fine for catching specific breakages. They are bad at measuring small improvements, and people forget that. On 40 cases, a 90% pass rate has a 95% interval of roughly 77% to 96% using the Wilson method above. At 34 of 40 (85%), the interval is roughly 71% to 93%. Those overlap almost completely, so "we went from 85% to 90%" is not evidence of anything on that set.

Two decision rules follow:

  1. Block on per-case regressions, which are meaningful even on 30 cases.
  2. Claim aggregate improvements only on a larger set, run nightly or before a release, and report the interval with the number. At 200 cases, the same 90% narrows to about 85% to 93%.

Running it in CI without lying to yourself

Decision My default Why
What triggers the gate Changes to prompts, model IDs, retrieval config, tool schemas, eval data Langfuse's list; a code-only change elsewhere shouldn't spend tokens
PR suite size Smoke subset of tagged critical cases, 3 trials Fast enough that people don't bypass it
Full suite Nightly and before release, 5 trials, judges on Catches what the subset misses, with tighter intervals
Model pinning Pin the task model and the judge model to dated versions An alias that moves under you turns the gate into noise
Response caching Cache key includes model version, prompt hash and inputs A cache keyed on input alone hides a provider-side change
Secrets Run the gate only where provider keys exist; label fork PRs for a maintainer run Fork PRs usually don't receive secrets and will fail confusingly
Enforcement Make the eval job a required status check Otherwise it is a suggestion

MLflow's continuous-evaluation guide makes the same point about comparing per scorer against the main-branch baseline rather than gating on one blended number. I'd push it one step further, to per case.

Online evals close the loop

Offline evals stop the regressions you've already named. They cannot see a shift in what users actually send. Online evals score a sample of live traffic, usually without a reference answer, using the same deterministic checks plus a judge, and they run asynchronously so the user never waits on a grader.

Sample every error and every piece of negative feedback, plus a fixed slice of normal traffic. Alert on a rolling trend per slice (model, prompt version, locale), not on a single bad score. Then do the step that gives the harness its value: turn each confirmed failure into a labeled golden case. LangChain's guide frames it the same way, with each production failure becoming both an offline test and an online check for recurrence.

Mentova's evaluation harness works on that weekly rhythm. It aggregates failed generations and the lessons from them, and improvements are applied to the pipeline every week, while every clip still passes automated checks and owner review before it ships. The per-run checks protect one customer; the weekly loop improves the system.

Questions a staff engineer will ask, and my answers

"Your eval passes but users complain. What's wrong?" The golden set no longer matches traffic. Check which production slices are missing from it and add their failures first.

"Why not just use one LLM judge for everything?" It is slower, costs money per case, and can be wrong in correlated ways. Deterministic checks catch most structural breakage for free, and the judge earns its place only after it agrees with humans on a labeled sample.

"How do you stop people from tuning to the eval?" Hold out a slice of cases that never appears in PR comments, and score it only before releases.

"Your suite hits 100%. Good news?" For a regression suite, yes. For a capability suite, it has saturated and stopped telling you anything. Add harder cases.

"What did this change cost?" Track latency and tokens per case as scorers too. A prompt that passes every case at twice the cost is a regression for most products.

Sources

  1. Demystifying evals for AI agents (Anthropic)anthropic.com
  2. Define success criteria and build evaluations (Claude Platform Docs)platform.claude.com
  3. EleutherAI lm-evaluation-harness (GitHub)github.com
  4. LLM regression testing: fail CI before regressions ship (Langfuse)langfuse.com
  5. Continuous LLM Evaluation: A Practical Guide for Production Teams (MLflow)mlflow.org
  6. LLM Evals: The Feedback Loop Behind Reliable AI Agents (LangChain)langchain.com