Promptfoo Explained: LLM Evals and Assertion Checks in CI
Promptfoo runs your prompts against test cases and checks each output with assertions. Learn the assertion types and how to gate prompt changes in CI.
By Galactic News Editorial · Published 2026-11-24T19:42:20+00:00 · Updated 2026-11-24T19:42:20+00:00
Promptfoo Explained: LLM Evals and Assertion Checks in CI
Prompts change, models change, and outputs drift. A prompt that worked last week can quietly break after a model update. Promptfoo is an open-source tool that catches those breaks before users do. It runs your prompts against test cases, checks each output with assertions, and reports a pass rate. Wired into CI, it turns a prompt change into a pull request gate, just like a unit test.
Promptfoo LLM Evals Assertion Checks CI: How It Works
Promptfoo works from one config file, promptfooconfig.yaml. The file declares three things: providers, prompts and tests. Providers are the models under test, written as vendor:model, for example openai:gpt-5-mini or anthropic:claude-haiku-4-5. Prompts are templates with {{variable}} placeholders. Tests supply the variables and the assertions for each case. Running promptfoo eval runs the cross-product of prompts, providers and tests. promptfoo view opens an HTML report of the results. Promptfoo supports more than 30 providers, including local models through Ollama.
Promptfoo announced in March 2026 that it was joining OpenAI. Its README says it remains open source and MIT licensed, and it still supports Anthropic, Google and local models. The tool requires Node.js 20.20 or newer, or 22.22 or newer for recent versions. Start with the built-in example: promptfoo init --example getting-started, then run the eval and view the report.
Assertion Checks: Deterministic First, Judge Second
Assertions are the heart of promptfoo. Each test case carries an assert array, and each assertion has a type and optional properties such as value, threshold and weight. Accuracy is defined as the share of prompts that produce the expected output. The rule of thumb is to write deterministic assertions first. They cost nothing beyond the model call, run in milliseconds and never flake.
| Assertion type | Passes when | Cost | Flaky |
|---|---|---|---|
| equals | Output matches exactly | Free | No |
| contains / icontains | Output contains a string | Free | No |
| regex | Output matches a pattern | Free | No |
| is-json / contains-json | Output is or contains valid JSON | Free | No |
| javascript / python | Custom function returns true | Free | No |
| latency | Response time under a threshold | Free | Rarely |
| cost | Cost per call under a threshold | Free | No |
| llm-rubric | A judge model rates the output against a rubric | One judge call | Sometimes |
| factuality | Output matches reference facts | One judge call | Sometimes |
| model-graded-closedqa | Output meets closed-QA criteria | One judge call | Sometimes |
Model-graded assertions cover what deterministic checks cannot: tone, faithfulness to context and answer relevance. The llm-rubric type grades output against a free-form rubric. factuality compares output against reference facts. Context-based types such as context-faithfulness, context-recall and context-relevance suit retrieval systems. Assertions can be grouped with assert-set, which passes only when its members meet a threshold, for example one of two checks or half of them. Each assertion can also carry a weight, so a critical check counts more than a nice-to-have one. Every assertion type can be negated by prepending not-, for example not-contains.
Running Evals in CI
The real value of promptfoo shows up in CI. A GitHub Actions workflow can run the eval suite on every pull request that touches a prompt, fail the build below a pass-rate threshold, and post a summary comment on the pull request. Responses can be cached so reruns cost nothing. The workflow pins the promptfoo version, validates the config with promptfoo validate, and runs the eval with the provider keys stored as repository secrets. One tested setup uses promptfoo 0.124.1 with Node 22.22 or newer and the promptfoo GitHub Action.
Good practice for CI evals is specific. Start with 20 to 50 golden cases taken from real traffic, with personal data removed, each describing behaviour you would be upset to lose. Put shared assertions in defaultTest so each test only states what is specific to it. Use a judge model that differs from the model under test, pinned to a version and run at temperature zero, so the grading stays stable. And treat the eval suite like code: review changes to prompts and tests in the same pull request.
Promptfoo Compared: Ways to Test a Prompt
| Approach | What it checks | Cost per check | Flakiness | Best for |
|---|---|---|---|---|
| Manual review | Whatever the reviewer notices | Reviewer time | High | One-off checks |
| Deterministic assertions | Format, content, cost, latency | Free | Almost none | Everyday regression gates |
| LLM-as-judge assertions | Tone, factuality, relevance | One judge call each | Some | Qualities code cannot measure |
| Full CI eval gate | Whole suite on every prompt change | Model calls plus judge calls | Low if thresholds are tuned | Production LLM features |
Setting Up a CI Eval Gate in Five Steps
- Install. Run
npm install -g promptfooor usenpx promptfoo@latest. Check that Node.js meets the version requirement. - Scaffold. Run
promptfoo init --example getting-startedand adapt the config to your prompts, providers and test cases. - Write deterministic assertions first. Add
is-json,contains,regex,latencyandcostchecks todefaultTest. - Add a judge for quality. Add
llm-rubricorfactualityassertions with explicit thresholds, using a different pinned model at temperature zero. - Wire up CI. Add a GitHub Actions workflow that validates the config, runs
promptfoo evalon pull requests touching prompts, fails below your pass-rate threshold, and posts the summary as a comment.
Limits: What Evals Cannot Prove
Evals measure the suite, not the product. A suite that passes on 50 easy cases can still miss the failure users hit on day one. Golden cases need regular refresh from real traffic, or the suite slowly drifts away from what users actually ask. Judge models carry their own biases and can disagree with human reviewers, so spot-check judge verdicts against human grades. Thresholds need tuning too: a pass-rate bar set too low waves through regressions, and one set too high blocks harmless prompt edits. Treat the eval suite as a living part of the codebase, and review it whenever the product changes.
Bottom Line
Promptfoo turns prompt quality into a testable, repeatable process. Deterministic assertions catch format and cost regressions for free. Judge assertions cover tone and factuality. CI turns the whole suite into a gate that blocks bad prompt changes before they ship. Start with a small golden set and a handful of cheap assertions, then grow the suite as the feature grows.