All posts

LLM evals in CI: how to regression-test prompts before a change reaches production

LLM evals in CI catch prompt and model regressions before users do. How to build a golden dataset, layer cheap checks before LLM-as-judge, and keep the eval bill under control.

CodeKrypt 5 min read

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:

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:

  1. The input exactly as the system receives it, including context.
  2. The expectation, written as checkable facts or a rubric rather than one reference answer.
  3. 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:

LayerWhat it checksCost per runCatches
Deterministic assertionsJSON validity, schema, required fields, length, banned phrasesNear zeroFormat breaks, missing fields
Programmatic grounding checksCited IDs exist, numbers match the source recordNear zeroFabricated references
LLM-as-judgeTone, completeness, relevance against a rubricToken cost per exampleQuality drift that rules cannot express
Human review of a sampleJudge calibration, new failure typesStaff timeEverything 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.

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:

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:

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?

  1. Pull 50 real inputs from your logs this week and write a one-line expectation for each.
  2. Add the deterministic checks first and run them in CI on every prompt change.
  3. Add an LLM judge only after you have hand-labelled 20 or so examples to calibrate it against.
  4. Add every production failure to the dataset the day it is found.
  5. 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.

CodeKrypt avatar

CodeKrypt

Drafted by CodeKrypt's AI writing pipeline, built and maintained by our engineers, under fixed rules on sources and claims. How we write

Frequently asked questions

What are LLM evals in CI?
They are automated tests that run your prompts against a fixed set of example inputs whenever a prompt, model or retrieval setting changes, and fail the build if quality drops below an agreed bar. They play the role unit tests play for ordinary code.
How big should a golden dataset be?
Practitioner guidance commonly suggests starting with roughly 50 to 200 inputs that resemble real production traffic, then growing it from real failures. A small, representative set you actually run beats a large one nobody maintains.
Can I just use an LLM as the judge?
As one layer, yes, but not as the only one. A judge model should be calibrated against a small set of human-labelled examples, and cheap deterministic checks (schema, required fields, forbidden content) should run first.
Will running evals on every pull request be expensive?
It can be if the suite is large. Run a small fast subset on every pull request, and the full suite on merges, nightly, or when a model or prompt template changes.

Related reading

Chat on WhatsApp