← All articles
LLM evaluation
MLOps
Production AI

Building an LLM evaluation harness that gates releases

· 7 minute read · Pivot-al

The usual sequence starts with a prompt change that ships to fix one complaint, and it does fix it. A few days later someone notices the assistant has stopped citing sources on a different class of question. Nobody caught it because nothing was measuring it, and nobody can say which change caused it because three things changed that week.

The team has a spreadsheet of test prompts, and someone eyeballs the outputs before a release, but it has no harness that can block a release on its own. This article describes the parts of one.

What "gates releases" means

An evaluation harness gates releases when three things are true:

  • It runs automatically on every change that can alter behavior: prompt, model version, retrieval configuration, tool schema.
  • It produces a pass or fail without a human reading outputs.
  • A fail stops the merge or the deploy, and people trust it enough not to override it by habit.

The third point is the hard one. A harness that flakes, or fails on cases nobody believes in, gets bypassed. Most of the design decisions below exist to keep the signal credible.

The golden set

The golden set is a small, versioned collection of cases with known expectations. Thirty to fifty cases is enough to start. A set that small will not measure quality precisely, but it will catch regressions on the things you already know matter.

Where the cases come from

Do not write them from imagination. Invented cases reflect what the team thinks users ask, and they are too clean. Source them from:

  • Real traffic. Sample production or pilot requests across the main intents. Include the ordinary ones. A harness made only of edge cases misses the day the common path breaks.
  • Real failures. Every bug report, bad answer flagged by support, and incident becomes a case. This is the highest-value source.
  • Known hard boundaries. Questions the system must refuse, questions with no answer in the corpus, requests that should trigger a tool and requests that must not.
  • Adversarial inputs. A few injection attempts and cross-tenant probes, if the system has tools or serves multiple customers.

Scrub personal data before the cases enter version control.

What a case contains

A case has to carry enough to be graded mechanically, so a prompt and an ideal answer are not enough.

- id: billing-refund-window-014
  source: support-escalation # where the case came from
  input:
      user_message: 'Can I still get a refund on the annual plan?'
      context:
          tenant: fixture-tenant-a
          plan: annual
          days_since_purchase: 41
  expectations:
      must_cite: ['refund-policy'] # document ids retrieval must surface
      must_include: ['30 days']
      must_not_include: ['yes, you can']
      rubric: answers-from-policy-v2 # model-graded criterion
  tags: [billing, policy, critical]

There is no single reference answer to string-match against. Free-text output has many correct forms, so the expectations describe properties a correct answer must have and leave the wording open.

Maintaining the set

Review a sample of the set on a schedule. Policies change and expected answers go stale; a stale case that fails for the wrong reason teaches people to ignore failures. Hold a portion of the cases back from day-to-day prompt iteration too. If every case is visible while tuning, you end up fitting the prompt to the set.

Graders, cheapest first

Use the cheapest grader that can decide the question, and run the graders in layers.

Exact and structural checks

Deterministic checks are fast, free and never flake:

  • Output parses as the required JSON schema.
  • The right tool was called with the right arguments, or no tool was called.
  • Retrieval returned the expected document ids in the top k.
  • Required strings are present; forbidden strings are absent.
  • Citations point to documents that were actually retrieved.

Many real regressions are caught here. A model upgrade that changes output formatting, or a chunking change that drops the right document out of the top results, fails structurally before any judgment about quality is needed.

Rubric-based model graders

For properties that need judgment, such as whether the answer is supported by the retrieved context, a second model applies a rubric. Three practices keep this reliable:

  • One criterion per grader. "Is every factual claim supported by the provided context?" is gradable. "Is this a good answer?" is not.
  • Binary or small categorical outputs. Pass or fail with a one-line reason. Ten-point scales produce numbers that look precise and drift between runs.
  • Pin the grader. The grader prompt and grader model version are part of the harness. If either changes, scores before and after are not comparable.

Calibrating the grader against human labels

A model grader is a classifier, so measure it against human labels before it gates anything:

  1. Collect a set of real outputs that includes failures. Fifty to a hundred is a reasonable start.
  2. Have a person who knows the domain label each one against the same rubric. Two labelers are better; their disagreements show where the rubric is ambiguous.
  3. Run the grader on the same outputs and compare.

Do not stop at overall agreement. If most outputs pass, a grader that says "pass" to everything agrees with humans most of the time. Look at the failures specifically: of the outputs humans marked as failing, how many did the grader catch, and of the ones the grader failed, how many did humans agree with. Fix the rubric wording until both are acceptable, then keep the labeled set. It is the regression test for the grader itself, and it gets rerun whenever the grader changes.

Regression evals in CI

Prompts, retrieval settings and model identifiers live in version control. A change to any of them triggers the eval run, the same way a code change triggers unit tests.

eval_gate:
    triggers: [prompts/**, retrieval/config.yaml, models.yaml, tools/**]
    runs_per_case: 3 # absorb sampling variance
    rules:
        - tag: critical
          require: all_pass # no tolerance
        - tag: '*'
          require: pass_rate >= baseline - 0.03
    on_fail: block_merge

The thresholds above are illustrative. The structure is the part to keep:

  • Two tiers. Critical cases (safety, isolation, tool misuse, the top revenue paths) must all pass. Everything else is compared with the baseline from the main branch, with a small tolerance.
  • Repeat runs. Model output varies between calls. Run each case several times and require a consistent result, or a flaky case will block good changes and get the gate disabled.
  • Report the diff along with the score. The output of a failed gate should list which cases flipped from pass to fail, with both outputs side by side.

Run the same suite when a provider retires a model version and you are forced to move.

Offline and online evaluation

Offline evaluation is everything above: fixed cases, run before release. It tells you whether a change broke something you already knew about.

Online evaluation measures live traffic and tells you whether the system is working for users now. Its signals include:

  • Explicit feedback, where it exists. It is sparse and skewed toward complaints.
  • Implicit signals: the user rephrases the same question, edits the generated draft heavily, abandons the session, or escalates to a human.
  • Sampled grading: run the same calibrated graders on a random sample of production traces.
  • Operational metrics: refusal rate, tool error rate, latency and cost per task.

You need both, because offline evals cannot see inputs you never thought of and online metrics arrive after users have seen the failure.

Tracing per request

Neither kind of evaluation works without traces. For every request, record the input, the retrieved chunks with ids and scores, the fully rendered prompt, the model and prompt versions, each tool call with arguments and result, the final output, latency and token counts, all under one request id.

Without this, a bad answer cannot be diagnosed, because you cannot tell whether retrieval missed the document, the model ignored it, or a tool returned garbage. Traces also feed the golden set: a failed production request is converted into a case by copying its trace.

In a representative, anonymized teardown we ran of a Series B B2B SaaS company's internal assistant, the system had no golden set and no tracing. A system in that state has no way to show that a change is safe, and every reported problem has to be investigated from scratch.

When offline and online disagree

They will disagree at some point, and each direction has a short list of usual causes.

Offline passes, online is poor:

  • The golden set no longer resembles traffic. Compare the intent distribution of the set with a recent sample of production requests.
  • The environments differ. The eval runs against a fixture index or without conversation history, and production has neither constraint.
  • The grader is lenient on a failure mode it was never calibrated for.

Offline fails, online looks fine:

  • Cases are stale or overly strict about wording.
  • The online metric is too coarse to see the regression. A stable thumbs-up rate does not show a rise in unsupported claims.

The procedure is the same either way: pull traces from the disagreement, have a human label them, and find out which side is wrong. If production is failing in ways the set does not cover, add those cases. If cases are stale, fix or retire them. The online signal tells you what users are getting, and the offline suite tells you whether a specific change is what broke it.

Where to start

If none of this exists yet, the order is: tracing first, then thirty cases from real traffic and known failures, then structural checks in CI, then one calibrated model grader for the property you care about most. With those four in place the harness can gate releases.

If the system has tools or serves several customers, the critical tier should include the cases described in tenant isolation in RAG and securing agents that call tools.

For a system already in production, our Production AI Audit covers eval coverage alongside a red-team run and cost per task. If you would rather talk through your current setup first, the teardown clinic is a free 30-minute session with a senior engineer.