Failing CI builds on promptfoo pass rates

Teams that gate LLM changes in CI need a pass-rate rule that blocks real regressions without failing every merge on model noise. This page covers exit codes, PROMPTFOO_PASS_RATE_THRESHOLD, margins and flaky model-graded checks.

On this page

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 optionWhen it fitsRegression it catchesMain risk
Zero-failure gateHard rules such as schema validity, required fields, banned output or refusal behavior that must never breakAny single case that flips from pass to fail, including new failures in previously stable casesOne 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 levelBroad drops in quality across the suite, such as a prompt change that degrades many cases at onceThe threshold is set without a baseline, so it either hides real regressions or fails on normal noise
Margin below baselineSuites where the current pass rate is known and changes should not reduce it beyond a small agreed toleranceGradual quality erosion that a fixed threshold would miss, measured against the last accepted runThe baseline drifts if updated automatically, and a margin set too wide lets regressions through
Deterministic assertions onlyChecks that produce the same result on every run, such as regex, JSON structure, length or exact string rulesFormatting, structure and rule breaks, with no variance from grader modelsCannot judge meaning or quality, so it misses regressions that read correctly but answer wrongly
Non-blocking report for model-graded assertionsLLM-as-a-judge checks whose scores vary between runs and need human review before they should block a mergeTrends and suspicious changes that reviewers can inspect in the report without stopping deliveryFailures 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.

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

  7. 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.

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 docs

Artifact 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 docs

Scoping 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

Sources and further reading

Talk to our team.

Tell us what you're working on, whether it's a deployment, an audit, a security test or a cyber range. You'll speak with an engineer who can help you scope it.

  • 30-minute call: free, with no obligation.
  • NDA on request: we can sign before you share details.
  • Clear next steps: a scope and plan after the call.