Evals That Actually Catch Regressions: Building a Test Suite for LLM Features
Vibes-based eval is how you ship a broken LLM feature on Friday. Here's how we build eval suites that catch real regressions before a model upgrade burns a customer.
Most teams we audit have exactly two states for their LLM features: "seems fine" and "on fire." There's rarely anything in between, because the eval layer is a spreadsheet one engineer maintained until they got bored. That's how a quiet Claude or GPT model update takes down your support bot on a Tuesday and nobody knows why.
This post is the eval playbook we actually use when shipping LLM features — what goes in the dataset, how we grade, and how we wire it into CI so a regression blocks a merge instead of a customer ticket.
Why "it looked good in staging" keeps failing you
LLM features fail differently than normal software. The code didn't change. The prompt didn't change. But Anthropic pushed a point release, or OpenAI silently rebalanced a tokenizer, or your retrieval index drifted by 2%, and now your extraction agent returns null for 8% of invoices it used to handle.
You can't catch this with unit tests over exact outputs — LLMs are non-deterministic even at temperature 0 in practice (see the OpenAI and Anthropic docs on reproducibility caveats, including seed being best-effort). You need evals: a dataset plus a grading function plus a threshold, run on every meaningful change.
The three changes that should trigger a full eval run:
- Prompt or system message edit
- Model version bump (including minor ones like
claude-sonnet-4-5→ next revision) - Retrieval, tool, or schema change upstream of the model
Build the dataset before you build the grader
The single biggest mistake we see: teams build a clever LLM-as-judge rubric before they have 50 real examples. Then they tune the rubric on vibes and declare the feature "95% accurate."
Start with data. Specifically, three buckets:
Golden set: the cases you must never regress on
30 – 100 examples, hand-curated, with known-correct outputs. These are the ones a PM or support lead would escalate if they broke. Keep this small enough that a human can skim all of them.
Adversarial set: the cases that broke in the past
Every production incident, bug report, and "this AI is dumb" screenshot becomes a row here. This set only grows. In our experience, this is the set that catches the most regressions after a model upgrade — because models get better on benchmarks and worse on your weird edge cases.
Sampled set: real traffic, anonymized
Rotate a sample of production inputs through weekly. This keeps your eval distribution honest. If 40% of your real queries are one-word fragments but your golden set is full paragraphs, your eval score is lying to you.
Pick a grading method that matches the task
Not every output needs an LLM judge. Reach for the cheapest grader that works.
| Task type | Grader |
|---|---|
| Classification, extraction, routing | Exact match / field-level diff |
| Structured output | JSON schema + semantic checks |
| Summarization, rewriting | LLM-as-judge with reference |
| Agent trajectories | Step-level assertions + final-state check |
| RAG answers | Groundedness + answer correctness, both scored |
For anything deterministic — did the model pick the right category, did it extract the right invoice number — don't use an LLM judge. You're adding cost, latency, and noise to grade something assertEqual handles for free.
When you do need LLM-as-judge, pin the judge
Use a different model family than the one you're evaluating, and pin the exact version. If you're shipping on Claude, judge with GPT-4.1 or Gemini 2.5 Pro, or vice versa. Anthropic's own eval guidance recommends pairwise comparison over absolute scoring when possible — asking "is A better than B?" is more reliable than "score A from 1 to 10."
A minimal judge prompt we actually use:
JUDGE_PROMPT = """You are grading an AI assistant's answer against a reference.
Question: {question}
Reference answer: {reference}
Candidate answer: {candidate}
Score the candidate on two axes:
1. factual_match: does it convey the same facts as the reference? (pass/fail)
2. groundedness: does it avoid adding facts not in the reference? (pass/fail)
Return JSON: {{"factual_match": bool, "groundedness": bool, "reason": str}}
Be strict. If the candidate adds plausible-sounding but unverified detail, groundedness fails.
"""
Run the judge 3 times per item and take majority vote. It's 3x the cost on the eval side but removes most of the judge's own flakiness.
Wire it into CI, not a notebook
An eval that lives in a notebook will be run once a quarter. An eval that blocks a PR will be run every time.
Here's the skeleton of how we structure it with pytest — framework-agnostic, works with Promptfoo, Braintrust, LangSmith, or your own harness:
import pytest
from myapp.features import classify_ticket
from evals.datasets import load_golden, load_adversarial
@pytest.mark.eval
@pytest.mark.parametrize("case", load_golden("ticket_classifier"))
def test_golden(case):
result = classify_ticket(case.input)
assert result.category == case.expected_category
@pytest.mark.eval
def test_adversarial_pass_rate():
cases = load_adversarial("ticket_classifier")
passes = sum(
1 for c in cases
if classify_ticket(c.input).category == c.expected_category
)
rate = passes / len(cases)
assert rate >= 0.92, f"Adversarial pass rate dropped to {rate:.1%}"
Two things we've learned the hard way:
- Separate golden from aggregate thresholds. Golden cases must all pass individually. Adversarial and sampled sets get an aggregate threshold. Mixing them hides regressions.
- Cache LLM responses by input hash during CI. If nothing upstream of the model changed, don't re-call the API. Your bill will thank you. Invalidate the cache on prompt or model version bumps.
Set thresholds from a baseline, not from hope
Don't set the threshold at 95% because it sounds good. Run the current production configuration on the eval set, see where it actually lands, then set the threshold 2 – 3 points below that. The eval is there to catch regressions, not to flunk your current system.
Agent evals are different — grade the trajectory
For single-turn LLM calls, grading the output is enough. For agents that loop, call tools, and make decisions, output-only grading misses most failures.
What we grade on agent runs:
- Tool-call validity: did it call real tools with valid arguments?
- Step count: did it finish within budget? Runaway loops are a regression even if the final answer is right.
- Unnecessary tool use: did it hit the database when the answer was in context?
- Final state: for task agents, did the world end up in the right state (ticket closed, PR opened, email sent to a test inbox)?
Record the full trajectory — messages, tool calls, tool results — as a JSON artifact per run. When something regresses, you diff trajectories between old and new model versions. That diff is usually where the bug lives.
The cost conversation
Evals cost money. A 500-example suite with an LLM judge run 3x can easily be $5 – $20 per full run. Multiply by every PR and you're looking at real spend.
How we keep it sane:
- Tier the suite. On every PR: golden + adversarial (~100 cases, cheap graders). Nightly: full sampled set with LLM judge. Pre-release: everything.
- Use smaller judges where you can. A Haiku or GPT-4.1-mini judge is often fine for straightforward factuality checks. Reserve the big judge for subjective quality.
- Cache aggressively. Deterministic graders don't need to re-run if the model output is cached.
- Prompt caching on the eval side too. If your system prompt is 2k tokens and you're running it 500 times, both Anthropic and OpenAI's prompt caching features can cut eval cost significantly.
In our experience, a well-tiered suite runs under $2 per PR and under $30 per nightly on mid-sized features. That's cheaper than one bad model upgrade reaching production.
Where we'd start
If you're staring at an LLM feature with no evals today, do this in order this week:
- Pull 30 real production inputs and hand-label the correct outputs. That's your golden set.
- Grep your incident log for every "the AI did something dumb" report. That's your adversarial set.
- Write the dumbest possible grader that works — exact match, JSON diff, or a one-shot LLM judge. Don't over-engineer.
- Put it behind
pytest -m evaland run it manually before every prompt or model change for two weeks. - Only then wire it into CI with thresholds you derived from a baseline run.
The teams that ship LLM features reliably aren't the ones with the fanciest eval frameworks. They're the ones who treat their eval set like a test suite: small, boring, versioned, and non-negotiable before merge. If you want help designing one for a production system, our AI engineering team does this work day in and day out.
Want a team like ours?
72Technologies builds production software for the kind of teams who actually read this blog.
Start a projectKeep reading
Hybrid Search for RAG: Why BM25 Still Beats Pure Vectors in 2026
Pure vector search sounds modern, but it quietly fails on acronyms, product codes, and exact phrases. Here's how we wire BM25 and dense retrieval together — and the reranking step most teams skip.
Tool Use That Doesn't Hallucinate: Designing Function Schemas LLMs Actually Respect
Function calling fails in boring, predictable ways: invented arguments, wrong enums, nested JSON that half-parses. Here's how we design tool schemas so Claude, GPT, and Gemini stop improvising.
Structured Outputs in 2026: When to Trust the Schema and When to Validate Twice
Structured output modes from OpenAI, Anthropic, and Google look identical on the slide deck. In production they fail in very different ways. Here's how we handle schemas without getting burned.
