Early-bird price on the GenAI & Agentic AI Engineer Bootcamp batch. Grab a seat →

LLM evaluation in CI: test sets, LLM judges and release gates

Build an evaluation pipeline that runs on every pull request: a versioned test set, deterministic checks, an LLM judge with a rubric, thresholds and a GitHub Actions workflow.

Related courseGen AI and Agentic AI for QA and Test Engineers
On this page
Diagram: An evaluation gate on a pull request

To evaluate an LLM application in CI, keep a versioned set of test cases in the repository, run cheap deterministic checks on every output first, score what code cannot check with a second model and a written rubric, and fail the build when pass rates fall below agreed thresholds. The pipeline runs on every pull request that touches a prompt, a model setting or the code around them.

This article is part of the LLMOps guide.

Key takeaways

  • The test set is a file in the repository, reviewed and versioned like code, and it grows from real failures.
  • Deterministic checks (parsing, required content, length) are free, fast and stable. Run them first and require all of them to pass.
  • An LLM judge needs a specific rubric and a constrained verdict such as PASS or FAIL. Anthropic's guidance is to judge with a different model from the one that produced the output.
  • A threshold turns scores into a release decision. Set it with the noise of the judge in mind.
  • Each run makes paid API calls, so limit when the workflow triggers.

What goes in the test set?

A test case is an input plus what a good output must satisfy. JSON Lines (one JSON object per line) works well because a diff shows exactly which cases were added or changed.

{"id": "refund-01", "question": "Can I return shoes after 40 days?", "must_include": ["30 days"], "must_not_include": ["full refund"], "max_chars": 600, "facts": "Returns are accepted within 30 days of delivery. After that, no refund."}
{"id": "offtopic-01", "question": "Write me a poem about cricket.", "must_include": ["order"], "must_not_include": [], "max_chars": 300, "facts": "The assistant only helps with orders and returns and should say so."}

Anthropic's documentation on building evaluations gives three principles that apply here: make the cases mirror your real task distribution and include edge cases, structure them so grading can be automated, and prefer volume over perfection. In its words, more questions with slightly lower-signal automated grading is better than fewer questions with high-quality human hand-graded evals. The edge cases it lists are a useful checklist: irrelevant input, overly long input, poor or harmful user input, and ambiguous cases where even people would disagree.

Add a case every time production produces a bad answer. That habit matters more than the starting size of the set.

Which checks should run first?

Run the checks that ordinary code can perform. They cost nothing, give the same result every time, and catch a large share of regressions:

  • the output parses (valid JSON, matches the schema)
  • required strings or fields are present
  • forbidden strings are absent (a competitor's name, a promise the business does not make)
  • length is within bounds
  • for classification, the label equals the expected label

A failed deterministic check is unambiguous, so require 100 per cent.

How do you use an LLM as a judge?

Some properties need reading comprehension: is the answer consistent with the policy, is the tone appropriate, did it invent a fact? For those, a second model call grades the output against a rubric. Three rules keep a judge useful.

  • Be specific. "Is this answer good?" produces noise. "Does the answer state every required fact and contradict none?" can be graded.
  • Constrain the verdict. Anthropic's examples tell the grader to output only a number or only "yes" or "no", which makes parsing trivial.
  • Use a different model. Anthropic's example code notes it is generally best practice to evaluate with a different model from the one that generated the output.

The script below runs both kinds of check and writes a report.

# evals/run.py
import json
import anthropic

client = anthropic.Anthropic()
APP_MODEL = "claude-haiku-5-5"
JUDGE_MODEL = "claude-sonnet-5-5"  # a different model from the one under test
SYSTEM = open("prompts/support_answer.md").read()

RUBRIC = """You are grading a customer-support answer.
Question: {question}
Answer: {answer}
Facts: {facts}
Reply PASS if the answer is consistent with every fact and invents no policy.
Otherwise reply FAIL. Output only PASS or FAIL."""

def ask(model, content, system=None, max_tokens=500):
    kwargs = {"system": system} if system else {}
    r = client.messages.create(
        model=model, max_tokens=max_tokens,
        messages=[{"role": "user", "content": content}], **kwargs,
    )
    return r.content[0].text

def deterministic_ok(case, answer):
    text = answer.lower()
    return (
        len(answer) <= case["max_chars"]
        and all(s.lower() in text for s in case["must_include"])
        and not any(s.lower() in text for s in case["must_not_include"])
    )

def judge_ok(case, answer):
    verdict = ask(JUDGE_MODEL, RUBRIC.format(answer=answer, **case), max_tokens=16)
    return verdict.strip().upper().startswith("PASS")

cases = [json.loads(line) for line in open("evals/cases.jsonl")]
results = []
for case in cases:
    answer = ask(APP_MODEL, case["question"], system=SYSTEM)
    results.append({"id": case["id"], "deterministic": deterministic_ok(case, answer),
                    "judge": judge_ok(case, answer), "answer": answer})

report = {
    "deterministic_pass_rate": sum(r["deterministic"] for r in results) / len(results),
    "judge_pass_rate": sum(r["judge"] for r in results) / len(results),
    "results": results,
}
json.dump(report, open("eval-report.json", "w"), indent=2)

A judge is a model too, so it can be wrong and it can vary between runs. Before trusting it, grade a sample of answers by hand and compare. If the judge disagrees with people often, fix the rubric. Keep the judge prompt in the repository: changing it changes every score.

How do thresholds block a release?

A separate, tiny script reads the report and exits with a non-zero status when a threshold is missed. A non-zero exit fails the step, and the job with it.

# evals/gate.py
import json, sys

report = json.load(open("eval-report.json"))
failures = []
if report["deterministic_pass_rate"] < 1.0:
    failures.append("deterministic checks must all pass")
if report["judge_pass_rate"] < 0.90:
    failures.append("judge pass rate is below 0.90")

print(json.dumps({k: v for k, v in report.items() if k != "results"}))
sys.exit("; ".join(failures) if failures else 0)

The 0.90 here is an example. Choose yours by running the current production version several times and setting the bar a little below its lowest score, so that normal judge variation does not fail the build. A threshold set at the best score ever seen gives a flaky pipeline that people learn to re-run and then ignore.

A flow of five steps from pull request to merge decision: pull request opened, deterministic checks, LLM judge, threshold gate, and merge or block.

What does the GitHub Actions workflow look like?

name: llm-evals

on:
  pull_request:
    paths:
      - 'prompts/**'
      - 'evals/**'
      - 'src/llm/**'
  workflow_dispatch:

permissions:
  contents: read

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true

jobs:
  evals:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-python@v7
        with:
          python-version: '3.13'
          cache: 'pip'
      - run: pip install -r requirements.txt
      - name: Run evaluation set
        run: python evals/run.py
        timeout-minutes: 15
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
      - uses: actions/upload-artifact@v7
        with:
          name: eval-report
          path: eval-report.json
          if-no-files-found: error
      - name: Enforce thresholds
        run: python evals/gate.py

Notes on the choices:

  • paths limits the trigger to changes that can affect model behaviour, so documentation edits do not spend API budget.
  • concurrency with cancel-in-progress stops an older run when a new commit arrives on the same branch.
  • The report is uploaded before the gate runs, so reviewers can read the failing answers.
  • The API key comes from the secrets context. GitHub states that secrets are not passed to the runner when a workflow is triggered from a forked repository, so this job cannot evaluate pull requests from forks as written.
  • To make the result binding, mark the job as a required status check in your branch protection rule or ruleset.

What are the limits?

  • Cost and time. Every case is at least two model calls. Keep the pull-request set small enough to finish in minutes, and run the full set nightly. Batch APIs suit the nightly run: Anthropic's Message Batches API is documented at half the standard price, with most batches finishing within an hour. How to reduce LLM costs has the details.
  • Noise. The application and the judge both vary between runs. Two runs of the same commit can differ by a case or two.
  • Coverage. The set only catches failures someone thought to write down. Production monitoring, described in LLM observability and tracing, finds the others.

For retrieval systems, the checks differ; see how to evaluate a RAG system.

Common questions

How many test cases do I need?

Enough to cover each behaviour you care about several times. Start with a few dozen drawn from real usage and add one for every production failure.

Should evals run on every commit?

Run them on every pull request that changes prompts, model settings or the code that builds the request. Run the larger set on a schedule.

Can the same model judge its own output?

It can, but Anthropic's guidance is to grade with a different model from the one that generated the output.

What if a prompt change improves some cases and breaks others?

That is the normal case. Read the per-case report, decide whether the broken cases matter, and record the decision in the pull request. The threshold is a floor, not a substitute for reading the failures.

Free download: LLM release evaluation kit

Build a regression suite for prompt, model, and workflow releases. Includes pass criteria, three worked test cases, and a run log you can use in release reviews. See what’s inside.

LLMOps: how to run LLM applications in production

What changes when you operate an LLM application: prompt and model versions, evaluations, tracing, cost per request and provider limits, with a minimum setup checklist.

Prompt versioning: treating prompts like code

How to keep prompts in the repository, review them like code, tie each version to a model and its evaluation results, label traces, and roll back safely.