A prompt edit looks harmless. Someone tightens a sentence, a provider
updates a model, a retrieval setting changes, and a week later support
tickets show that one category of answer quietly got worse. LLM evals in
CI exist to catch that on the pull request instead of in production.
This post covers what to test, how to build the test set, and how to keep
the whole thing affordable.
What are LLM evals in CI, and why not just unit test?
Ordinary unit tests assert exact outputs. A language model gives different
wording each time, so exact-match assertions fail on harmless variation
and pass on subtle errors. Evals replace "is this output identical?" with
"does this output meet the bar?", scored across a set of examples.
The common pattern, described in write-ups such as
Traceloop's guide to prompt regression testing,
is to run a candidate prompt against a standard dataset, compare scores to
the current production prompt, and fail the build on a regression, the same
way a failing unit test would.
Three things should trigger the suite:
- a prompt or system-message change
- a model change, including a provider's silent version update (see our
model deprecation and migration plan)
- a change to retrieval, tools or output schemas
How do you build a golden dataset?
Start from real traffic, not imagination. Pull representative inputs from
production logs, add the edge cases support has already complained about,
and write down what a good answer must contain. Guidance from practitioner
sources generally suggests starting small, on the order of 50 to 200
examples, and growing it deliberately.
What each example needs:
- The input exactly as the system receives it, including context.
- The expectation, written as checkable facts or a rubric rather than
one reference answer.
- A category tag, so you can see that "refund questions" regressed
while "shipping questions" did not.
Then feed the set continuously. Every production incident, bad
user-feedback rating and newly discovered attack pattern becomes a new
test case. Datasets that never absorb new failures go stale, and a stale
suite gives false confidence.
Which checks should run first?
Order the checks cheapest first. Many teams jump straight to using a
second model as judge and pay for it on every run. A layered approach
keeps cost and noise down:
| Layer | What it checks | Cost per run | Catches |
|---|
| Deterministic assertions | JSON validity, schema, required fields, length, banned phrases | Near zero | Format breaks, missing fields |
| Programmatic grounding checks | Cited IDs exist, numbers match the source record | Near zero | Fabricated references |
| LLM-as-judge | Tone, completeness, relevance against a rubric | Token cost per example | Quality drift that rules cannot express |
| Human review of a sample | Judge calibration, new failure types | Staff time | Everything the judge misses |
If your outputs are structured, the first layer does a surprising amount
of work, and it pairs naturally with
reliable structured output.
Can you trust an LLM-as-judge?
Conditionally. Sources on this topic are consistent that a judge model is
useful but not authoritative: it has its own biases and can be confidently
wrong. Treat it as an instrument that needs calibration.
- Keep a small set of human-labelled examples and measure how often the
judge agrees with the humans. If agreement is poor, fix the rubric before
trusting any score.
- Write rubrics as specific yes/no questions ("Does the answer state the
refund window?") rather than "rate quality 1 to 10".
- Pin the judge model version, and re-calibrate when you change it. A
judge that drifts makes your regression signal meaningless.
- Judge with a different model from the one being tested where you can, to
reduce self-preference.
How do you stop evals from becoming a cost problem?
CI cost and runtime grow quickly with large scenario suites, and every
example costs tokens on both the system under test and the judge. Ways to
contain it:
- Two tiers. A small smoke set (a few dozen cases, deterministic checks
plus a light judge pass) on every pull request; the full suite on merge,
nightly, or whenever a model or template changes.
- Cache unchanged cases. If neither the prompt nor the inputs affecting
a case changed, reuse the previous result.
- Use a cheaper judge for coarse gates, and the stronger one only on
failures or borderline scores.
- Use the same savings levers as production, such as the ones in
reducing LLM API costs and
prompt caching.
How should the pass/fail gate work?
Do not gate on a single global average; one category can collapse while the
mean barely moves. A workable gate:
- Hard-fail on any deterministic check regression (broken schema, banned
content).
- Fail when any category drops by more than an agreed margin against the
production baseline.
- Warn, rather than fail, on small movements inside the noise, and run
borderline cases multiple times since outputs vary.
- Always store the per-example results as a build artefact so a reviewer can
read the actual failing outputs, not just a score.
Tools such as Promptfoo are frequently cited for wiring this into GitHub
Actions with JUnit or JSON output, but the design above is tool-independent.
How do evals relate to agent testing?
Agents add tool calls and multi-step state, so the "expectation" includes
which tools were called and in what order. The same layered approach
applies; our AI agent evaluation framework
covers what to check before an agent goes live, and
why AI agents fail in production
shows the failure types worth turning into test cases.
What should you do next?
- Pull 50 real inputs from your logs this week and write a one-line
expectation for each.
- Add the deterministic checks first and run them in CI on every prompt
change.
- Add an LLM judge only after you have hand-labelled 20 or so examples to
calibrate it against.
- Add every production failure to the dataset the day it is found.
- Split the suite into a fast pull-request tier and a full nightly tier.
If you are shipping AI features inside a SaaS product and want an eval
pipeline designed alongside them, see our
AI SaaS development service.