Skip to content
mentoor

Topic 1 of 5 · 4 min read

Running eval suites in CI

Goal: Configure a CI job that runs a fast eval suite on each pull request and a full suite nightly within a cost budget.

Run a small, fast eval suite on every pull request that can change AI behaviour, and a large, slow suite on a schedule, so each gets feedback in the time and money it can afford. An eval suite is a set of test cases plus graders. Treat it like your unit tests: if it only runs when someone remembers, it will not run.

Check yourself · 1 of 3

Which suite belongs on every pull request that edits a prompt?

Choose one answer

Why it matters

LLM features break without a compile error. A reworded prompt, a changed retrieval setting or a new tool description can lower quality while every conventional test stays green. CI is the one place every change passes through, so it is the cheapest place to catch the drop.

Two tiers

  1. Pull request tier (the smoke suite). 30 to 100 cases, mostly code graders (exact match, schema, regex, tool-call checks) and a few cached judge calls. It finishes in a few minutes and costs cents. Run it only when relevant paths change: prompts, model config, retrieval code, tool definitions. Use path filters in the workflow trigger.
  2. Nightly tier (the full suite). Hundreds or thousands of cases, LLM judges, multi-step agent runs, repeated trials for flaky cases. It can take an hour and cost real money, so run it on a schedule and on release branches.

Controlling cost and time

  • Cache model responses keyed by prompt, model and parameters. An unchanged case should not call the API again. Promptfoo and Inspect both support result caching; keep the cache directory in the CI cache.
  • Set a budget. Cap cases, cap tokens per case and cap total spend per run, and fail the job clearly when the cap is hit instead of silently running a subset.
  • Run cases concurrently, with a rate-limit-aware retry, so a 5-minute suite does not take 40.
  • Use secrets properly. The API key lives in CI secrets. Pull requests from forks do not get them, so decide up front what those runs do (skip, or run only code graders).

Report where people look

Post a short summary as a pull request comment: pass rate, change versus the base branch, the cases that newly fail, and a link to the full report. Upload the raw results as a build artifact so a failure can be inspected without rerunning.

Before and after

Before: a team runs evals on a laptop before big launches. A prompt edit on Tuesday lowers refund-question accuracy, and nobody notices for two weeks. After: the pull request touching prompts/ runs the 60-case smoke suite, comments "refund: 18/20 to 14/20", and the author sees it before merging.

What goes wrong

  • The smoke suite grows until it takes 25 minutes and people stop waiting for it. Keep it small and move slow cases to nightly.
  • No cache and no cap, so a retry loop in one test burns a month's budget in a night.
  • The job passes because it ran zero cases after a path or config error. Fail when the case count is below the expected count.

Examples

A two-trigger workflow

on:
  pull_request:
    paths: ["prompts/**", "src/rag/**", "evals/**"]
  schedule:
    - cron: "0 2 * * *"
jobs:
  evals:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/cache@v4
        with:
          path: ~/.cache/promptfoo
          key: evals-${{ hashFiles('prompts/**', 'evals/**') }}
      - run: npx promptfoo eval -c evals/${{ github.event_name == 'schedule' && 'full' || 'smoke' }}.yaml --max-concurrency 8
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}

Pull requests that touch prompts, retrieval or the evals themselves run the smoke config. The 02:00 schedule runs the full one. The cache key changes only when prompts or evals change.

The silent empty run

A refactor renames evals/cases/ to evals/data/. The job loads zero cases, reports 0 of 0 failed, and goes green. Adding a check such as expected_cases >= 60 turns that into a red build on the first run.

Key points

  • Run a small, cheap smoke suite on each pull request that touches prompts, model config or retrieval, and a full suite on a schedule.
  • Cache model responses and cap cases, tokens and spend per run so cost stays predictable.
  • Fail the job when the number of cases run is lower than expected, so a broken config cannot pass silently.
  • Post pass rate, change versus the base branch and newly failing cases on the pull request, and keep raw results as an artifact.
  • Decide in advance what runs for fork pull requests that have no access to API secrets.

Common mistakes

  • Running the full suite on every pull request until it is slow and expensive, then disabling it.
  • Running evals only before releases, so regressions are found weeks after the change that caused them.
  • Setting no spend cap, so a retry loop or a doubled dataset multiplies the bill unnoticed.
  • Treating a green job as proof without checking that the expected number of cases actually ran.

Check yourself · 2 of 3

An eval job turns green after a refactor, but it ran 0 cases because the data folder was renamed. What is the best fix?

Choose one answer

Check yourself · 3 of 3

Your nightly eval bill doubled after a dataset grew. Which change reduces cost without lowering the number of cases checked?

Choose one answer

Practice items, not counted towards your mastery.

Start here