· 10 min read
My AI pipeline got more accurate and broke its promise. CI caught it.
TwoPass part 3: a pull-request gate that checks the 95% promise, not just accuracy, and says what the fix will cost
Contents

The pull request raised accuracy, cut the share of rows sent to a person from 2.5% to 0.5%, and made every 1,000 rows 20% cheaper. My CI blocked it, and it was right.
Some context first. TwoPass makes one promise: the rows it accepts on its own are at least 95% right. In part 1 I built it: a cheap decision model answers what it’s sure of, a cheap writer model takes the rest, a stronger model re-runs whatever gets rejected, and anything still uncertain goes to a person. In part 2 I took the same idea to pulling fields out of forms. This part is about what happens after launch, when the code keeps changing.
The worry
A promise is only as good as the next pull request.
A lot of changes can move it. A prompt edit. A model swap. A new checker version. A threshold refit. Any of them can make accepted rows a little less right without anything crashing. Nothing turns red. The dashboard numbers might even go up.
So I built a CI gate. It runs on changes that could move the promise, re-checks it, and posts one comment on the pull request. Then I tried to fool it.
The PR that looks great
Here’s the change I care most about. I refit the thresholds at a 93% target “to automate more”, and left the promise at 95%. It sounds reasonable in a standup.
In the real CI run on PR #11, here is what it did to the numbers I’d normally watch:
- Auto-accepted: 97.5% → 99.5%
- Sent to a person: 2.5% → 0.5%
- Accuracy: 93.8% → 94.3%
- Cost per 1,000 rows: $0.504 → $0.403
Better on every dashboard number. That’s the point.

The red comment on PR #11: 94.7% right against a floor of 94.8%. Both accuracy gates passed it.
The gate blocked it. The first line of the comment says why: auto-accepted rows were 94.7% right (CI 93.4–95.7%), and the floor is 94.8%. Auto-accepted but wrong went from 65 rows to 82. That’s 17 more wrong answers nobody would look at, against an allowance of 3.

Was the gate right? I checked the change against the full Banking77 test split, 3,080 rows the CI never sees. Accuracy went up 0.3 points. Precision of the auto-accepted rows went from 95.6% to 94.3% (CI 93.4–95.0%). The promise broke on data the gate had never touched.
Why accuracy gates miss it
Most eval gates in CI watch one number: did accuracy, or the pass rate, drop? Tools like promptfoo make that easy, and it’s the right default. So I ran two accuracy gates next to mine:
- G1: accuracy must stay above my lowest noise run, minus 0.5 points.
- G2: a bootstrap of the paired difference, base vs. head on the same rows, must not show a drop bigger than 1 point.
- G3: the promise gate. This is the one that’s enforced.
Then I put a handful of changes through all three, in a separate bench run. Here’s what each gate said:
# Change G1 G2 G3 Test split
6 Refit at 93% pass pass BLOCK 95.6% → 94.3%
6r 6 + gate's proposal pass pass pass 96.0%
1 Jev 1.14 → 1.13 pass pass BLOCK not run
3 Clef → Jev block block block not run
0a README edit (no-op) pass pass pass not run
Change 3 is the easy one. Anything catches a 14-point drop. Change 6 is the hard one. Accuracy went up, so both accuracy gates waved it through. On the two changes I could check against the test split, G3 was right both times, and G1 and G2 were wrong on change 6.
Accuracy counts every row. The promise counts only the rows nobody checks. A lower threshold lets more rows through without a person. Some of the extra rows are right, so accuracy goes up. But the share that’s wrong among the unchecked rows goes up too. The two numbers can move in opposite directions, and a gate that watches one can’t see the other.

Change 1 is a quieter version of the same thing. Swapping Jev 1.14 for 1.13 with the old thresholds left accuracy flat (−0.06) and dropped precision 0.71 points. G3 blocked it. Normally the gate wouldn’t even get that far: it refuses thresholds fitted for a different checker ID, and 1.13 and 1.14 have different IDs. I forced it with an override to copy what happens when an alias like jev-latest moves to a new version under you. That’s the real risk. A new checker version can change what its confidence numbers mean, and an alias won’t tell you it changed.
How the gate decides
Before deciding what “worse” means, I needed to know how much the numbers move when nothing changes. Nothing in this pipeline is deterministic. Haiku 5.5 and Sonnet 5.5 won’t even accept a temperature setting, and in a probe Clef’s confidence moved by up to 0.29 on identical input. So I ran unchanged code 8 times on the same 1,540-row slice:
- Accepted precision: 95.59–95.79%. A spread of 0.2 points.
- Accuracy: 93.83–94.09%.
- Auto-accepted but wrong: 63–66 rows.
- Up to 17 answers flip between two runs. 97.2% of rows are identical in all 8.
So it isn’t deterministic, but it’s quiet, and now I know exactly how quiet.
None of the 56 ordered pairs of those runs is blocked by any gate. Zero false alarms on unchanged code.
That gives the floor: the 95% target minus the 0.2 points of measured noise, so 94.8%. G3 checks three things. Head’s precision must be at or above that floor, and the top of its confidence interval must not sit below base. No single label may lose more rows than unchanged code loses. And auto-accepted-but-wrong rows may not rise by more than unchanged code moves them, which on this slice is 3.
My first version used the textbook rule: block unless the Wilson lower bound on precision is at least 95%. It sounds rigorous. It fails. When true precision sits right at the target, the lower bound on about 1,500 accepted rows lands near 94%. The gate would block nearly every PR, including the ones that change nothing. A gate that always fails gets switched off.
Building it taught me one more thing: per-stage fits don’t add up. TwoPass fits a threshold for each of its three stages, and each was fitted to at least 95% on its own. Replayed on its own 1,000 calibration rows, part 1’s Clef fit gives 94.6% end to end. The promise has to be checked on the whole pipeline, not stage by stage.
The gate has blind spots too. Each label has 20 rows in the slice, so the smallest drop it can see in one label is 3 rows (15 points) for 76 labels, and 4 rows for one. It guards the overall promise well. It guards any single label poorly.
What the comment gives you
A red X alone isn’t much help. The comment also proposes a fix.

Every dashboard number improved. The proposal: thresholds refitted on 800 calibration rows, checked on 200 held out.
On the 200 held-out rows, the proposed thresholds take precision from 95.0% to 97.4%, and they send 4.5% of rows back to a person to do it.
It doesn’t say “fixed”. It says what the fix costs. On the full test split, compared with main, the price was 0.7 points of automation: auto-accept went from 97.4% to 96.7%, and precision came in at 96.0% (CI 95.2–96.6%). Promise restored, 0.7 points less automation. That’s a product decision, and the reviewer should make it knowingly.
The comment also lists 10 rows to read, riskiest auto-accepted first. It hides the gold labels on purpose, so the reviewer judges. Afterwards I checked them against the gold labels. 4 of the 10 really were wrong, and all four had been auto-accepted.
Then I committed the proposal in PR #12, and the same check went green.

PR #12, proposal applied: the same check goes green.
The promise held at 96.0%, and the price matched the proposal: about a point more rows go to a person. The 16 answers that flipped are fewer than unchanged main flips on its own.
Cost and setup
Base and head run on the same slice in the same job. The CI calls are synchronous, not batched, so a run takes minutes instead of hours.
The red run cost $1.40 at list price ($0.78 base, $0.62 head) and took 7 minutes, 4 of them downloading Banking77. The green run cost $1.47, with 110 s and 102 s per side.
The surprise: the checker costs more than the writer. Clef’s 77-option prompt is about 2,100 tokens and has no cache price. Haiku reads its 1,941-token label list from cache. The whole experiment, demo runs included, cost about $16.
Because of that $1.40, TwoPass’s own workflow is manual: Actions → Run workflow. If you copy it, yours runs on pull requests unless you change that.
The catch with a manual button: nothing runs unless I press it. Clef has no version in its model ID, and it comes through OpenRouter (DeepInfra on every one of my runs), so it could change under the same name, and I’d only find out the next time I press the button. Jev has real versions (1.13, 1.14) that you can pin.
To set it up on your own data:
twopass gate init --data your.csv --text col --label col
It writes the task config, calibration rows, CI slice and a GitHub workflow in about a second, with no API calls. TwoPass isn’t on npm yet, so for now install from a clone. As for how much data you need: about 35 or more labelled rows per label, and at least 200 calibration rows. With less, the thresholds overfit. My 32-row smoke-test fixture did, so the comment now warns when fewer than 30 held-out rows are accepted.
What it doesn’t do yet
It has seen one dataset. Everything above is Banking77 with one checker setup. I don’t know yet how the noise floor or the 0.7-point price looks on messier data, and that’s the main thing I want to find out.
It only handles classification. The extraction pipeline from part 2 has no gate yet, because “right” there means every field in a document, not one label.
Most of the matrix is CI-slice only. I paid for test-split runs on change 6 and its fix, because that’s where the argument lives. The Jev rows are weaker evidence: the Jev base was already below the promise at 94.0%, and I never measured Jev’s noise, so the gate treated it as zero.
And the slice isn’t production. Both the slice and the test split come from Banking77. Real traffic drifts, and the gate can only check the rows you give it.
What’s new here, and trying it
None of the pieces here are new. Gating pull requests on evals is what promptfoo’s GitHub Action does. Running unchanged code several times to see the noise is standard advice. Fitting a threshold so a classifier that may abstain meets a target error rate goes back to Geifman and El-Yaniv’s 2017 work on selective classification, and Learn Then Test and conformal risk control put guarantees on it. What I hadn’t seen was a gate that checks that promise on every PR, instead of accuracy.
The code is at github.com/Rubick1997/twopass. The gate’s docs are in docs/eval-gate.md, and every number in this post is in bench/gate/. The red and green demo PRs (#11 and #12) are still readable, comments included.
The thing I’d most like is a dataset to try it on. If you have a labelled classification task where a wrong auto-accepted answer costs you something, tell me. I’ll run the gate on it and write up what breaks.