One Flaky Agent Step Doesn't Need a Bigger Model. Let It Vote.
When one agent decision is flaky, upgrading the whole model may be wasteful. Sample that step several times, normalize the outputs, vote, stop early when the result is locked, and escalate disagreement instead of mistaking consensus for certainty.
On this page
Yesterday's reliability article answered one question:
Which part of the agent is actually flaky?
Once you have that answer, the next temptation is to upgrade the entire agent to a larger model.
Sometimes that is justified.
Often it is wasteful.
If one classification, routing decision, or extracted field is the unstable part, I would rather spend extra compute only on that step.
Run it several times.
Normalize the outputs.
Let the answers vote.
That is the practical version of consensus sampling.
It borrows the same core idea as self-consistency: sample multiple reasoning paths instead of trusting one draw, then use agreement across the outputs to choose a result.
The important word is sample.
Calling the exact same deterministic path five times is not redundancy. It is paying five times for the same opinion.
The math is attractive for one reason
Suppose a single run is wrong 10% of the time.
If the errors across runs are independent enough, then a five-sample majority is only wrong when at least three of the five samples are wrong together.
That probability is much smaller than 10%.
function majorityError( p: number, n: number,): number { if (n % 2 === 0) { throw new Error("Use an odd sample count"); } const choose = ( total: number, k: number, ) => { let result = 1; for (let i = 1; i <= k; i++) { result *= (total - (k - i)) / i; } return result; }; const need = Math.floor(n / 2) + 1; let error = 0; for (let k = need; k <= n; k++) { error += choose(n, k) * p ** k * (1 - p) ** (n - k); } return error;}console.log( majorityError(0.10, 5),); // ~0.00856A 10% single-run error becomes roughly 0.86% with five independent samples.
With nine samples it falls to about 0.09%.
That looks almost magical.
It is not.
It is the binomial tail doing exactly what it should do when the errors are sufficiently independent.
That last condition is the one that matters.
Put consensus around the weak step, not the whole agent
I would not wrap every model call in five samples.
That turns a reliability technique into a latency and cost problem.
Use the repeated-run eval from the previous article to find the one or two decisions that are both:
- unstable;
- important enough that a wrong answer matters.
Good candidates are usually discrete:
refund | escalate | denyfraud | safebilling | technical | salescustomer_id = 4821tool = issue_refundThose outputs can be normalized and counted.
A long free-form summary is much harder to vote on because two equally good answers may share almost no exact wording.
Consensus works best when the answer space is well defined.
Normalize before you vote
The sampler is easy.
The boring normalization layer is where a lot of implementations break.
These two outputs mean the same thing:
{"action":"refund","reason":"duplicate"}{ "reason": "duplicate", "action": "refund"}A raw string vote would treat them as different answers.
For structured agent steps, parse first and canonicalize second.
type Vote = { answer: string; agreement: number; samples: number;};function canonical(raw: string): string { try { const value = JSON.parse(raw); return JSON.stringify( value, Object.keys(value).sort(), ); } catch { return raw.trim().toLowerCase(); }}async function consensusSample( callStep: () => Promise<string>, n = 5,): Promise<Vote> { const raw = await Promise.all( Array.from( { length: n }, () => callStep(), ), ); const counts = new Map<string, number>(); for (const item of raw) { const answer = canonical(item); counts.set( answer, (counts.get(answer) ?? 0) + 1, ); } const [answer, count] = [...counts.entries()].sort( (a, b) => b[1] - a[1], )[0]; return { answer, agreement: count / n, samples: n, };}The important part is not the Counter.
It is defining what "same answer" actually means for that step.
If you cannot define equivalence reliably, majority voting may be the wrong aggregator.
The runtime should look like this
The vote is not the final security boundary.
It is a reliability layer around one uncertain model decision.
A destructive action should still pass through the same authorization, approval, idempotency, and policy controls it needed before consensus existed.
Five models voting to issue a refund do not create permission to issue the refund.
They only make the classification step less flaky.
Do not spend all five samples when three already settled it
Fixed-size sampling is easy to reason about, but it can waste money on obvious inputs.
Suppose the maximum budget is seven samples.
After four samples, one answer already has four votes.
The remaining three samples cannot overturn it.
The outcome is mathematically locked.
Stop.
async function consensusEarlyStop( callStep: () => Promise<string>, maxSamples = 7,) { const counts = new Map<string, number>(); for ( let drawn = 1; drawn <= maxSamples; drawn++ ) { const answer = canonical( await callStep(), ); counts.set( answer, (counts.get(answer) ?? 0) + 1, ); const [leader, votes] = [...counts.entries()].sort( (a, b) => b[1] - a[1], )[0]; const remaining = maxSamples - drawn; const runnerUp = [...counts.entries()] .filter(([key]) => key !== leader) .sort((a, b) => b[1] - a[1])[0]?.[1] ?? 0; if (votes > runnerUp + remaining) { return { answer: leader, agreement: votes / drawn, samples: drawn, }; } } return null;}This changes the cost profile.
Easy inputs settle quickly.
Only ambiguous inputs use the full budget.
That is usually where the extra compute is worth spending anyway.
The dangerous failure: everyone agrees and everyone is wrong
This is the part that keeps consensus sampling from being a universal reliability button.
Majority voting reduces variance.
It does not automatically remove shared bias.
If every sample sees the same misleading wording, missing field, stale document, or biased framing, they can all make the same mistake.
Recent work on wrong-consensus agreement shows exactly this problem: high agreement can still occur on incorrect answers, particularly on difficult cases. Agreement is useful evidence, but it is not proof of correctness. citeturn381951academia34
That means I would never wire:
5/5 agree→ automatically trust the answerwithout asking whether those five samples had any realistic chance to disagree.
There are a few ways to create diversity:
- nonzero sampling temperature;
- different prompt framings;
- reordered choices;
- different retrieved evidence ordering;
- two model families instead of one;
- an independent rule-based verifier for the final decision.
The goal is not random disagreement.
The goal is to reduce the chance that every sample inherits the same failure mode.
Use three outcomes, not two
I prefer consensus to return one of three states:
strong agreement→ continuemixed agreement→ independent verifierreal disagreement→ escalateLow agreement is valuable information.
It says the input is near an unstable boundary.
Do not hide that signal by sampling forever until a majority eventually appears.
If the first few samples split 3–2 on a high-risk action, I would rather route that case to a stronger verifier or human than congratulate the majority for winning by one vote.
Where consensus sampling earns its cost
I would use it for narrow steps where three things are true:
The step is measurable. You know from evals that it is genuinely flaky.
The answer is comparable. A vote can tell when two outputs mean the same thing.
The mistake is expensive enough to justify redundancy.
That makes classification, routing, extraction, tool selection, and high-risk yes/no gates good candidates.
I would not use it for every paragraph an agent writes.
And I would not use it to compensate for deterministic problems such as a broken tool, stale permission state, missing database constraint, or bad authorization rule.
Those failures need engineering fixes, not more samples.
The takeaway
Once you measure agent reliability per step, you do not always need a bigger model to improve the weakest link.
Sometimes the cheaper fix is redundancy.
Sample the flaky decision several times, normalize the outputs, vote, stop early when the winner cannot be overturned, and treat disagreement as a reason to verify or escalate.
The math can reduce independent errors dramatically.
But consensus is not correctness.
If every sample shares the same bad assumption, five wrong answers are still wrong.
Use voting to reduce stochastic failure.
Use independent verification to catch shared failure.
And apply both only where your evals show the extra work is buying something real.
References
KEEP READING
Related engineering notes
A Failover Route Is Not a Recovery Path: Proving Independence in AI Infrastructure
Two LLM providers can share the same failure domain. Build an evidence-backed recovery graph that checks cloud, networking, identity, control-plane and capacity dependencies before admitting fallback routes, then test correlated outages without weakening safety.
Read articleAn Eval Platform Sunset Can Erase Your Release Evidence: Build an Evidence-Escrow Migration Gate
When a hosted LLM evaluation platform retires, switching runners is not enough. Preserve the historical evidence, reconstruct grader semantics, validate scoring parity, and enforce a fail-closed release gate that survives the service shutdown.
Read articleWhen the Package Runs Before Your App: Quarantining AI Framework Releases
The 2026 agent-framework PyPI compromise exposed a blind spot in AI build pipelines: Python startup hooks execute before application imports. Design an artifact-quarantine gate, inspect wheels without installing them, separate credentials, and recover from suspected exposure.
Read article