Blogaireliabilitytestingstatisticsai-agentsengineering
You Can't Prove an AI Is Correct. Here's What You Can Prove.
I run AI agents in production every day. They write code, draft blog posts, triage mail and deploy services. People ask me how I know they work. The honest answer is that I can't prove they do. What I can do is narrower, and I think more useful: I can measure how often they fail, say how sure I am of that number, and make sure the actions that really matter don't depend on the AI getting it right.
The temptation
Software engineers are used to certainty. A unit test passes or fails. A type checker accepts the program or rejects it. For critical code you can go further and prove properties formally: this function never overflows, this lock is never held twice. So it's natural to ask for the same thing from AI. Write the tests, run the proof, ship.
It doesn't work, and it's worth being clear about why.
Why a proof fails
A proof needs three things that AI output doesn't give you.
A formal specification. To prove a sort function correct, you write down what "sorted" means. Nobody can write down what a "good" summary, a "correct" email reply or a "helpful" answer means in a way a proof checker could use. If you can't state the property, you can't prove it.
Determinism. The same prompt can give different outputs from one run to the next. A proof about one output says nothing about the next.
A finite input space. The inputs are natural language, documents, code and whatever else users send. For practical purposes the space is infinite. You can't check every case, and you can't reduce it to a handful of cases the way you can for a parser with a grammar.
So "this AI is correct" is not a claim anyone can prove. Anyone who tells you they have proven it is using the word loosely.
Borrow from manufacturing and statistics
Factories have lived with this problem for a century. You can't prove every bolt off the line is good, so you sample, count defects and put a number on the rate. AI tasks fit the same frame. Treat each task as a trial: it passed or it failed, by a check you decide on in advance. Then use the statistics that already exist for pass/fail trials.
The rule of three
If you run n trials and see zero failures, the 95% upper bound on the failure rate is about 3/n. This is the rule of three, from Hanley and Lippman-Hand's 1983 JAMA paper, "If nothing goes wrong, is everything alright?". It comes from solving (1 − p)^n = 0.05: the smallest rate p that would make n clean runs a 5% fluke. Since ln(0.05) is about −3.0, the bound is about 3/n.
So 300 clean runs lets you say the failure rate is below 1% with 95% confidence (the exact bound is 0.994%). 3,000 clean runs gets you below 0.1%.
Notice what that means. Three hundred perfect runs, which feels like a lot when you're watching them, supports "under 1%". Not "never fails". Not "99.9% reliable".
Confidence intervals when you do see failures
Usually you see some failures. Say 7 in 1,000. The point estimate is 0.7%, but that alone hides how uncertain it is. The Wilson score interval (E. B. Wilson, 1927) behaves well at small rates, where the textbook "plus or minus" interval breaks down. For 7 failures in 1,000, the Wilson 95% interval is 0.34% to 1.44%.
That's the number to report: "between about 0.3% and 1.4%", not "0.7%". The true rate could plausibly be twice the point estimate.
What Six Sigma would take
Six Sigma is the manufacturing benchmark: 3.4 defects per million opportunities. To claim it with 95% confidence and zero observed failures, you need n = ln(0.05) / ln(1 − 3.4 × 10⁻⁶) clean runs. That works out to 881,097 runs in a row with no failure.
Here is the whole picture. Both columns are computed; the rule of three is the quick approximation, the exact column solves (1 − p)^n ≤ 0.05.
| Failure rate you want to claim | Rule of three (3/p) | Exact clean runs needed |
|---|---|---|
| 1% | 300 | 299 |
| 0.1% | 3,000 | 2,995 |
| 0.01% | 30,000 | 29,956 |
| Six Sigma (3.4 per million) | 882,353 | 881,097 |
Most claims of "reliable AI" that I see rest on an evaluation set of a few hundred examples. Even if every one of them passed, that supports roughly "under 1%". It's a real result. It's just a much smaller one than the marketing usually suggests.
The sampling trap
All of these numbers carry a condition that's easy to forget: they only hold if your test set looks like real use. A clean run on the wrong sample tells you about the sample, not about production.
Anthropic's engineering post Migrating our Messages API to Rust (November 25, 2026) shows this very clearly. Their Rust version passed about 98% of its tests in April, yet only about a quarter of inputs matched the old Python API on production traffic; their chart starts at 24%. They closed the gap by running real requests through the old and new code and comparing the results, which they call shadowing. Since the model itself is non-deterministic, they ran it once and replayed its output to both. The match rate climbed to 99.6%.
The tests weren't wrong. They just didn't look like production. A 98% pass rate on the wrong distribution meant about a quarter on the right one. If your evaluation set was written by the same people, or the same model, that built the system, assume it shares the system's blind spots.
Prove what you can, measure the rest
So you can't prove the AI. But an AI system is never only the model. Around the model there's ordinary code: what it's allowed to call, where its output goes, what happens before anything irreversible. That code can be tested exhaustively and, where it matters, verified formally. The architecture I use is a deterministic shell around a probabilistic core.
Prove the deterministic parts
Permission checks, spend limits and "never send without approval" are plain code. They take a small, well-defined input (this command, this amount, this recipient) and return yes or no. You can enumerate the cases, test every one, and prove properties about them.
In my own setup, every AI agent session runs behind a policy guard that sits outside the AI. The guard decides which commands a session may run, in which exact forms, and against which projects. An agent can decide whatever it likes; if the action isn't on the list, the guard refuses it. Sending real email, spending money and touching secrets stay gated by rules the model can't edit. I don't need to trust the model's judgment on those actions, because its judgment never reaches them.
Differential testing against a trusted reference
When you have a trusted reference, compare against it, exactly as Anthropic did with the old Python API. My compiler project, GoPatina, translates Go to Rust. It checks every translated program by building and running it and comparing its output with what Go itself prints.
On a corpus of real Go programs written for people, Go by Example and A Tour of Go, 138 programs can be tested today. GoPatina accepts 31 of them, and all 31 match Go's output exactly. It refuses the other 107, naming the Go feature it doesn't support yet, rather than guessing at a translation. A low acceptance rate with exact matches is something I can build on. A high acceptance rate with silent mistakes would be worse than nothing.
Property checks at runtime
Some properties must hold for every output, and many of them can be checked by code even when the output can't. "Never names a product that doesn't exist" is one: compare every product name in the text against the real list.
On November 26 the blog autopilot for pigfox.com wrote a draft that named a product called "Pigfox Prompt". There is no such product. The invented-name check dropped the draft, so nothing false was published. The model made a mistake; the shell caught it. That's the design working, not failing.
Keep counting in production
The statistics above are a snapshot. Inputs drift, models get updated, prompts change. So keep counting passes and failures on live traffic, and let the interval update as the data comes in. A weekly scorecard is enough for most systems: trials, failures, the 95% interval, and whether it moved. GoPatina's parity run does this every Monday and fails if fewer programs get through than in the recorded baseline.
The sentence you're allowed to say
Put together, here is the strongest honest claim I know how to make about an AI system:
"On a sample representative of real use, the failure rate is below X% with 95% confidence, and the actions that matter (money, sending, deleting) are gated by code that is proven, not guessed."
It's less exciting than "our AI is accurate". It's also true, checkable and useful to the people who depend on the system.
A checklist for teams
- Define pass and fail before you test. Write the check first, so the results can't bend it.
- Sample from real use. Replay or shadow production traffic where you can. Treat a hand-written test set as a starting point, not the answer.
- Report intervals, not point estimates. Use the rule of three for zero failures and the Wilson interval otherwise.
- Know how many runs your claim needs. Under 1% takes about 300 clean runs; under 0.1% takes about 3,000.
- Put irreversible actions behind deterministic code. Money, sending and deleting go through checks the model can't change, and you test those checks exhaustively.
- Check properties on every output. If a rule can be checked by code, check it before the output leaves the system.
- Keep counting in production. A weekly scorecard catches drift before your users do.
If you want to see how AI crawlers and answer engines read your own site, pigfox.ai has free tools for that, with no sign-up.