How promptfoo pass-rate gates fail a CI build
A prompt or model change should not reach production without a measurable check, and in a CI pipeline that check is a pass-rate gate. promptfoo runs evals from its command-line interface, so the pipeline step is a job that runs the eval and reads the result. The build fails when the command returns a failing exit status, which promptfoo sets when the pass rate falls below the level your configuration requires. Because promptfoo runs on the machine executing the job and talks directly to the model provider, the CI runner needs network access to that provider, the provider credentials, and a supported Node.js version (the npm release 0.124.1 requires Node.js 22.22.0 or newer). Confirm the exact exit code and threshold behavior for your installed version in the promptfoo documentation before you make it a merge rule.
Use a blocking gate when the change could alter what users receive: edits to system prompts, model version swaps, retrieval settings or provider configuration. Use a report-only run when the test suite is still being built, when you are comparing candidate models, or when a scheduled run is meant to show trends rather than block a merge. The rules are set by your team's own configuration, and DeployOpen does not recommend a fixed threshold, because the right pass rate depends on how many cases the suite contains, which assertions it uses and how much regression your users can tolerate. Decide who owns the threshold value and where it is stored, and require the same review for changing it as for changing the prompt it protects.
How a merge request flows through an eval gate
The flow starts when a developer pushes a merge request, which triggers the CI job. The job runs the promptfoo eval, and the run ends with a pass rate that the gate compares against the configured threshold. A pass rate at or above the threshold returns exit code 0 and the merge is allowed; below it, the job returns a non-zero exit code and the merge is blocked. Model-graded failures that the team has flagged as flaky go to a human review branch instead of blocking, so reviewers should check which failures were routed there and why.
Eval results decide the exit code, and flagged model-graded failures go to human review.
Which gate setting fits which kind of check
This table compares five ways to gate an LLM change in CI: a zero-failure gate, a pass-rate threshold, a margin below baseline, deterministic assertions only, and a non-blocking report for model-graded checks. Read each row for when the option fits, what regression it catches and its main risk. Most teams combine two or more of these rather than picking one.
| Gate option | When it fits | Regression it catches | Main risk |
|---|---|---|---|
| Zero-failure gate | Hard rules such as schema validity, required fields, banned output or refusal behavior that must never break | Any single case that flips from pass to fail, including new failures in previously stable cases | One unstable or ambiguous case blocks every merge, so teams start skipping or ignoring the gate |
| Pass-rate threshold (PROMPTFOO_PASS_RATE_THRESHOLD) | Suites with many cases where a small number of failures is expected and the team has agreed an acceptable level | Broad drops in quality across the suite, such as a prompt change that degrades many cases at once | The threshold is set without a baseline, so it either hides real regressions or fails on normal noise |
| Margin below baseline | Suites where the current pass rate is known and changes should not reduce it beyond a small agreed tolerance | Gradual quality erosion that a fixed threshold would miss, measured against the last accepted run | The baseline drifts if updated automatically, and a margin set too wide lets regressions through |
| Deterministic assertions only | Checks that produce the same result on every run, such as regex, JSON structure, length or exact string rules | Formatting, structure and rule breaks, with no variance from grader models | Cannot judge meaning or quality, so it misses regressions that read correctly but answer wrongly |
| Non-blocking report for model-graded assertions | LLM-as-a-judge checks whose scores vary between runs and need human review before they should block a merge | Trends and suspicious changes that reviewers can inspect in the report without stopping delivery | Failures are easy to ignore, so the team needs an owner and a plan for promoting stable checks to blocking |
Setting up a pass-rate gate in your pipeline
This sequence takes a pipeline from an unpinned eval run to a job that fails when a prompt change drops below your agreed pass rate and passes when it holds. The result is a gate your team has tested with both a failing and a passing change before it becomes a required merge check.
Pin Node.js and promptfoo versions
The pipeline owner sets the build image to Node.js 22.22.0 or newer, the minimum for promptfoo npm release 0.124.1, and pins the promptfoo version in the job so every run uses the same CLI. Record both versions in the pipeline file and the repository README so reviewers can see them. Done when the job log prints the Node.js version and the promptfoo version, and both match the pinned values.
Fix the eval config and inputs
The engineer who owns the prompts commits a promptfoo configuration file with the prompt files, provider model identifiers, test cases and assertions in version control. Pin model identifiers wherever your provider allows it, because a provider-side model update can change results without any change to your repository. Done when two local runs from a clean checkout report the same pass count on unchanged prompts. If the counts differ, grading or the provider is adding noise, so fix that before setting a gate.
Confirm exit code and threshold behavior
Before writing the gate, read the promptfoo documentation to confirm which exit code the CLI returns when assertions fail and how PROMPTFOO_PASS_RATE_THRESHOLD is read, including its accepted format and whether it is compared against a percentage or a fraction. Record the answers in the pipeline README, since behavior can change between releases. Done when a local run with the threshold set above your current pass rate exits with a failure code, and a run set below it exits with success.
Add the eval command as a required job
The pipeline owner adds a dedicated stage that runs the eval command, with the threshold set as a pipeline variable so teams can change it through review. The job should fail when the command returns a failure code, so do not wrap the command in a trailing shell command or continue-on-error setting that hides that code. Mark the job as required for merge in your Git platform. Done when a forced failure turns the job red and blocks the merge button.
Verify a failing change blocks the build
On a test branch, the prompt owner makes a deliberate change that should degrade output, for example an illustrative edit that removes an instruction that an assertion checks for. Open a merge request and confirm the eval job fails, the report lists the failing test cases, and the merge is blocked. Done when the failure reproduces on a second push, which shows the gate responds to the change itself and was not caused by grader noise.
Verify a passing change clears the gate
Make a harmless edit to a prompt, such as a formatting change that should leave answers intact, and open a merge request. Confirm the eval job passes, the pass rate in the report stays above the threshold, and the merge is allowed. Done when the passing change clears the gate on two consecutive runs. If it fails intermittently, review the model-graded assertions before loosening the threshold.
Confirm cache and secrets handling
The pipeline owner stores provider keys as masked or protected secret variables in the CI system and confirms the promptfoo cache directory persists between runs, with a cache key tied to the prompts and config. Check the job log for exposed key values and confirm a second run on unchanged inputs reports cache hits. Done when keys do not appear in logs or artifacts and an unchanged re-run makes fewer provider calls. Confirm the cache setting names in the promptfoo documentation for your pinned version.
Stopping flaky model-graded checks from blocking every merge
Start by sorting every assertion in your suite into two groups. Deterministic assertions check things a machine can verify exactly, such as required JSON keys, a regex match, a maximum length, a forbidden string, or a tool call with specific arguments. LLM-as-a-judge assertions ask a grader model to score an output against a rubric, which makes their results probabilistic. Only the deterministic group should decide whether a merge is blocked by default, because a failure there is reproducible and usually points at a real change in prompt or code.
- Tag each assertion by type: Keep a clear naming or config convention so reviewers can see which checks are model-graded before they read a failure.
- Gate on deterministic failures first: Set the blocking pass-rate threshold against the deterministic subset, then report judge results separately.
- Keep safety-critical checks deterministic where possible: Refusal phrases, PII patterns and schema validity can usually be expressed without a grader.
- Avoid mixing both types in one score: A single blended pass rate hides which kind of check moved and makes margins hard to reason about.
- Record the split in the config: Put the grouping in a shared file so the CI job and the reviewers read the same definition.
Before changing any gate, check which of your assertions call a grader model and confirm the exact assertion types in the promptfoo documentation for your version.
A common pattern is to run the full suite, including model-graded checks, in a separate job that does not block merges. The blocking job runs the deterministic assertions on every change, while the judge job runs on a schedule, on a release branch, or on merge requests marked for review. Results from the advisory job still land in the pipeline so reviewers can see trends, but a noisy grader cannot stop a deploy by itself.
- Use a second job or stage: Mark the judge job as allowed to fail in your CI system so its exit code does not fail the pipeline.
- Run judges on a schedule: A nightly or weekly run gives a trend line without spending grader tokens on every commit.
- Trigger judges on prompt changes: Path filters on prompt and config files keep judge runs tied to the changes most likely to affect them.
- Publish judge results as artifacts: Keep the output file so reviewers can open it without rerunning the suite.
- Promote judges to blocking only after they stabilize: Move a check into the gate once its variance is known and its failures are trusted.
Confirm how your CI system handles allow-failure settings and whether its scheduler and path filters match the triggers your team uses.
Many judge failures come from the grader rather than the application under test. Ambiguous rubrics, a grader prompt that asks for several judgments at once, or a sampling temperature above zero can all produce different verdicts for the same output. Tightening the grader before setting any margin reduces the variance you have to absorb. Keep the grader model, its version and its settings pinned in config so a provider-side change does not look like a regression in your prompt.
- Write narrow rubrics: Ask the grader one question with a defined pass condition rather than a general quality score.
- Lower or fix the temperature: Set the grader temperature to a low value and record it in the config, and confirm the setting is supported by the provider you use.
- Pin the grader model and version: Treat a grader change like a tooling change and review it with the same care.
- Give examples of pass and fail: Few-shot examples in the grader prompt often make verdicts more consistent.
- Log the grader reasoning: Keep the explanation next to each verdict so you can see why a check flipped.
Test any grader change against a fixed set of outputs with known verdicts before trusting it in CI.
A margin should come from measured variance, not from a guess. Run the same suite several times on an unchanged build and record the pass rate for each run, separately for deterministic and judge checks. The spread between runs tells you how much a score can move with no code change, and that spread is the baseline a margin has to cover. The number of repetitions is a judgment for your team, so choose enough runs to see a stable range and document the choice.
- Repeat on an unchanged commit: Any difference between runs comes from the model, the grader or the environment.
- Record per-check results: A stable overall rate can hide one check that flips every run.
- Set the margin above observed noise: Derive the threshold from the range you measured, then review it after prompt changes.
- Repeat when the grader or provider changes: Variance measured against one model version does not carry over to another.
- Keep the measurement in version control: Store the run summaries so the margin has a traceable basis.
Ask your provider and grader vendor how their outputs vary across identical requests, and confirm the repetition approach against the promptfoo documentation for your version.
Some judge failures are real but acceptable for a given change, such as a tone shift that a product owner has reviewed, or a known grader disagreement on an edge case. Without a record, the same failure blocks the same merge repeatedly and people start overriding the gate informally. A reviewed-exception file, kept in the repository and changed through code review, gives auditors and engineers a clear trail of what was accepted, by whom and why.
- Name the reviewer and reason: Each accepted failure should identify the test, the output version and the approving role.
- Scope acceptances narrowly: Tie an exception to a specific test case and prompt version, so it expires when the prompt changes.
- Review exceptions on a set cadence: Stale acceptances should be removed or re-approved.
- Keep the record under code review: Changes to the exception file should follow the same approval path as code.
- Feed accepted failures back into the rubric: Repeated acceptances usually mean the grader or the rubric needs work.
Check with your compliance and product owners how exception approvals must be documented before you build this process.
When a margin beats zero failures
A zero-failure gate fits a suite that gives the same answer on every run, such as deterministic assertions on structured output or a small set of exact-match checks. In that case any failure is a real signal and a single failing case should block the merge. Larger suites that include model-graded assertions or sampled outputs behave differently. The same prompt can pass on one run and fail on the next, so a zero-failure gate turns normal variance into blocked merges. Before choosing a margin, run the unchanged suite several times on the same commit and record how many cases flip between passing and failing. That observed spread, not a number chosen in advance, is the basis for the threshold.
A margin is a trade. Setting PROMPTFOO_PASS_RATE_THRESHOLD below 100 percent lets a run pass while some cases fail, so a regression that affects only a few cases can reach the main branch without anyone being stopped. A tighter margin catches more real regressions but blocks more merges on noise. Teams often make this choice worse by setting the margin too loose to stop complaints, which quietly removes the gate. Decide which failures are acceptable (for example, cases known to be unstable under the grader model) and treat critical safety or policy cases as zero-tolerance, either by keeping them in a separate config or by reviewing those results in the job output regardless of the overall rate.
Review the threshold whenever the model, prompt set or dataset changes, because the variance it was based on no longer applies. A new grader model, a different provider version or a larger test set can each move the baseline. Confirm the current threshold and the exit behavior in the promptfoo documentation for your installed version, and record the baseline run results alongside the config so the next reviewer can see where the margin came from. Keep the threshold in version control with the eval config so changes go through review like any other quality decision.
Secrets, logs and reports in gated pipelines
A pass-rate gate is only as trustworthy as the pipeline around it. The cards below cover where provider keys live, what eval artifacts reveal, how long they persist and who can change the threshold or the config that enforces it.
Provider keys in masked variables
Eval runs call your model provider with a key stored in the CI system, so that key is the main secret in the job. Store it as a masked and protected variable rather than in the repository, and confirm that the CI system hides it in job logs, including when a script echoes environment variables. Check that forked or external merge requests cannot read the key, because a pull request from an untrusted branch can otherwise print it through a modified config.
Prompts and responses in eval output
Promptfoo result files can contain the full prompt, the test input and the model response for every case. For a red team run, the outputs may also contain attack strings and sample sensitive data from your application. Treat the JSON, HTML and JUnit files as confidential records, review what your test data contains before publishing them as artifacts, and confirm which fields your reporter writes.
Self-hosting docsArtifact retention periods
CI systems keep job artifacts for a configurable period, and that period is often longer than anyone remembers setting. Decide how long eval reports should live, set the retention in the pipeline rather than relying on the project default, and remove reports from old branches. Ask your platform team who can download artifacts from a finished job, since a retained report is readable by anyone with that access.
Who can change the threshold
The pass-rate threshold and the test config are both inputs to the gate, so changing either can quietly weaken it. Put the threshold in a file or variable that changes only through reviewed merge requests, protect the branches that define the gate, and require code owners for changes to the promptfoo config and the CI job. Review any commit that lowers a threshold or removes an assertion as a policy change.
Self-hosted server access boundaries
If CI uploads results to a self-hosted promptfoo server, that server becomes a second store of prompts and responses. The open-source self-hosted app uses a local SQLite database, has no RBAC, and is not recommended for production use. Before sending pipeline results to it, confirm where the server runs, who can reach it, and whether the access controls your organization requires exist in the version you deploy.
Self-hosting docsScoping secrets to the gate job
A provider key that serves every job in the pipeline gives every job, including build and deploy steps, the ability to spend against it or read it. Scope the eval key to the job or stage that runs promptfoo, use a key with a spend limit where your provider offers one, and rotate it when people with pipeline edit rights change. Confirm that the job cannot print the key to artifacts through debug output.
Questions teams ask before setting pass-rate gates
How much effort does building a pass-rate gate take?
The effort depends less on the gate itself than on the test suite behind it. Setting PROMPTFOO_PASS_RATE_THRESHOLD or a non-zero failure allowance takes minutes, but a gate is only useful when the suite reflects real application behavior. The main drivers are the number of prompts and providers under test, how many test cases each prompt needs, how many assertions are model-graded, and how much time goes into reviewing the first baseline run. Ask any partner or internal lead for a written breakdown of these components, separating one-time setup from the recurring work of updating cases when prompts change.
Can an internal team set up pass-rate gates on its own?
Yes, many teams can, provided one or two engineers know the application under test and are comfortable with Node.js, CI configuration and the promptfoo CLI. The harder part is usually judgment rather than tooling: deciding which failures should block a merge, which assertions need a human-reviewed baseline, and how to handle flaky model-graded checks. Teams with no one who owns evaluation quality, or with no time to review failing runs, often struggle to keep the gate trustworthy after the first month. A partner is most useful for a fixed-scope first build with written acceptance criteria, after which the team keeps ownership.
What does the work need from our team?
Three things are needed before the gate can run reliably. First, a named owner for the eval suite who can approve test cases and explain changes in pass rates. Second, provider API keys for the models under test and for any grader model, stored as masked CI variables or in your secrets manager, with a budget and rate limit agreed in advance. Third, CI access to create or modify pipeline jobs, cache directories and report artifacts in the systems you already run. Ask for a list of these access requests at the start so security review does not delay the first run.
How long does rollout take for a small suite compared with a large one?
Rollout time follows suite size and grader design more than any other factor. A small suite with deterministic assertions, such as string checks, JSON schema validation and regex matches, can usually be wired into a pipeline quickly and run in a single pass. Larger suites with many model-graded assertions need more time for baseline runs, for calibrating the grader against human judgments, and for setting thresholds that tolerate normal variation. Each grader model adds cost and latency to every run. Ask for a timeline that separates baseline capture, threshold calibration and the period in which the gate runs in warning mode before it blocks merges.
Do we need a partner to capture the first baseline?
A partner is not required, but the first baseline is where most teams make avoidable mistakes. The baseline sets the reference pass rate that future merges are measured against, so a baseline built from a poorly chosen set of cases or from a single noisy run can lock in misleading thresholds. An outside reviewer can check case coverage, confirm that model-graded checks are stable across repeated runs, and document the threshold rationale. Whether you bring in help or not, record who approved the baseline, which model versions and grader settings it used, and when it should be recaptured.
Why do model-graded checks keep blocking every merge?
Model-graded checks often vary between runs because the grader model, the target model or sampling settings are not fixed. A check that passes most of the time can fail on an unrelated change, and teams then either disable the gate or raise the margin until it means nothing. Stabilize the grader first by pinning its version and temperature, rewriting vague rubrics into specific criteria, and running the same case several times to measure its spread. Use a deterministic assertion wherever one can express the requirement, and reserve blocking status for checks that have been stable over repeated runs.
What should we confirm with promptfoo before relying on the gate?
Confirm the behavior of the version you deploy, because CI behavior around exit codes and threshold settings should be checked against that release rather than assumed. The current npm release requires a supported Node.js version, so confirm the runner image meets that requirement. Review the release notes on GitHub before upgrading, since changes to grading or caching can shift pass rates without any change to your prompts. The promptfoo documentation describes how the CLI runs locally and calls providers directly, so also confirm that your provider usage, data handling and network egress match your security policy.
How DeployOpen works on this
DeployOpen plans and implements promptfoo gates in the CI system and infrastructure your organization controls, starting from a written scope. The work covers exit code behavior, pass-rate thresholds, grader stability and the handover your engineers need to run the gates without us.
How we scope
- Agree in writing which pipelines, branches and merge request types the gate applies to
- Record the pass-rate policy per suite, including where a margin is allowed and who approves it
- Confirm which model-graded checks run on every merge and which move to scheduled runs
- Define the provider keys, runner environments and cache locations the gate depends on
How we build
- Configure the promptfoo command so failing thresholds return a non-zero exit code the CI job reads
- Set PROMPTFOO_PASS_RATE_THRESHOLD per suite and test the gate against passing and failing sample runs
- Pin the promptfoo version and Node.js runtime so gate results do not shift between builds
- Measure grader variance across repeated runs and adjust assertions before they block merges
How we hand over
- Deliver the pipeline configuration, threshold settings and a short runbook for failing gates
- Document how to read the reports, retry flaky checks and record an approved margin change
- Walk your platform and AI engineers through the gate with a test merge request they run themselves
- Provide a list of open questions to confirm with your model providers and CI vendor
How we support
- Engagements are fixed-scope, with scope, deliverables and timelines agreed in writing before work starts
- Ongoing support, upgrades and continuous testing are available as a retainer
- Retainers can cover promptfoo version upgrades and review of threshold changes over time
- Ask for a quote based on the written scope, since DeployOpen does not publish a price list

