Sub topic 3
Running LLM Regression Tests in CI
This chapter assumes basic Python, pytest, LLM API calls, Git, and GitHub Actions. The goal is to run fast regression checks on pull requests while reserving expensive checks for scheduled runs.
Running the suite in CI
Run evaluations when prompts, application code, or test cases change. Keep the API key in repository secrets.
name: llm-evals
on:
pull_request:
paths:
- "app/**"
- "prompts/**"
- "evals/**"
jobs:
fast-evals:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install -r requirements.txt
- run: pytest evals/fast -q
env:
LLM_API_KEY: ${{ secrets.LLM_API_KEY }}The workflow should fail when a required format, phrase, safety rule, or pass-rate threshold fails. Store detailed results as CI artifacts so a failure can be investigated after the job ends.
Controlling cost and runtime with test tiers
Use tiers instead of running every case on every commit.
- Fast: deterministic checks and a small representative dataset on pull requests.
- Full: the complete golden dataset after merging or on a schedule.
- Extended: repeated runs, judge-based checks, and adversarial cases nightly.
This keeps feedback quick while still checking broader behavior regularly.
Pinning versions and detecting drift
Pin the model identifier, API parameters, and relevant dependency versions. Record them with every evaluation result. A provider may change behavior behind a stable-looking alias, so compare scheduled results with the stored baseline. A sudden score change can indicate model drift rather than an application edit.
Reporting and triaging failures
Report total cases, pass rate, failed case IDs, model metadata, and a short output excerpt. Triage each failure as an application defect, an evaluator defect, expected variance, or model drift. Do not overwrite the baseline merely to make CI green.
Maintaining datasets and baselines
Version golden cases with the application. Add a case when a production failure or important edge case appears. Remove obsolete cases only with a documented reason. When behavior intentionally changes, attach the design decision and human review to the baseline update.
Exercise
A pull request changes only a prompt. Which checks should run immediately, and which can wait?
Show answer
Run the fast tier immediately. Run the full and extended tiers on a schedule or before merging when the prompt change affects broader behavior.