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 LLM evals assertion checks CI explained

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 typePasses whenCostFlaky
equalsOutput matches exactlyFreeNo
contains / icontainsOutput contains a stringFreeNo
regexOutput matches a patternFreeNo
is-json / contains-jsonOutput is or contains valid JSONFreeNo
javascript / pythonCustom function returns trueFreeNo
latencyResponse time under a thresholdFreeRarely
costCost per call under a thresholdFreeNo
llm-rubricA judge model rates the output against a rubricOne judge callSometimes
factualityOutput matches reference factsOne judge callSometimes
model-graded-closedqaOutput meets closed-QA criteriaOne judge callSometimes

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

ApproachWhat it checksCost per checkFlakinessBest for
Manual reviewWhatever the reviewer noticesReviewer timeHighOne-off checks
Deterministic assertionsFormat, content, cost, latencyFreeAlmost noneEveryday regression gates
LLM-as-judge assertionsTone, factuality, relevanceOne judge call eachSomeQualities code cannot measure
Full CI eval gateWhole suite on every prompt changeModel calls plus judge callsLow if thresholds are tunedProduction LLM features

Setting Up a CI Eval Gate in Five Steps

  1. Install. Run npm install -g promptfoo or use npx promptfoo@latest. Check that Node.js meets the version requirement.
  2. Scaffold. Run promptfoo init --example getting-started and adapt the config to your prompts, providers and test cases.
  3. Write deterministic assertions first. Add is-json, contains, regex, latency and cost checks to defaultTest.
  4. Add a judge for quality. Add llm-rubric or factuality assertions with explicit thresholds, using a different pinned model at temperature zero.
  5. Wire up CI. Add a GitHub Actions workflow that validates the config, runs promptfoo eval on 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.