Redundancy and retries
Parallel reliability, \(1-(1-p)^k\), and the common-cause ceiling
Takeaway
Retrying up to times at % per attempt should succeed 97% of the time. When % of failures share a cause, it succeeds 90%, and no number of retries gets past 91%.
Change the blue numbers. Every figure on this page updates with them.
Why care
Retries are the cheapest reliability fix in an agent, and the most over-trusted one.
The textbook formula assumes every attempt fails for its own reasons. Real attempts share a model, a prompt, an input and a context window, so when one fails for a structural reason (a missing table, an ambiguous question, a tool that is down) the next attempt usually fails the same way. That shared part sets a ceiling that no retry count can cross. This page shows how to find the ceiling, how to measure it from your own traces, and how to raise it.
Everything here assumes you can tell a good attempt from a bad one: a test, a schema check, a verifier. Without a checker, choosing among k answers is a voting problem, covered in M10.
The intuition
Asking the same colleague the same question three times helps if they misheard you. It does nothing if they don't know the answer. Independent failures are the mishearing kind; common-cause failures are the not-knowing kind.
Only the independent slice shrinks as you add attempts. The shared slice stays exactly where it is, so the success curve flattens at \(1-\beta q\) instead of climbing to 100%.
The math
With \(k\) attempts that fail independently, the task fails only if every attempt fails:
To allow for shared causes, split each attempt's failure probability \(q\) into a common-cause part \(\beta q\) that knocks out every attempt at once, and an independent part. This is the beta-factor model from safety engineering:
- \(p\)
- probability a single attempt succeeds; \(q = 1-p\)
- \(k\)
- maximum number of attempts (retries plus the first try, or parallel samples)
- \(\beta\)
- share of failures that come from a cause every attempt shares
- \(q_i\)
- failure probability of an attempt once the shared cause is ruled out
- \(r\)
- repeat-failure rate: share of failed cases that fail again on one retry
Four results matter in practice:
- The ceiling: with infinitely many attempts you still fail on the shared slice, \(\beta q\). At \(p = 0.7\) and \(\beta = 0.3\), that caps success at 91%.
- Measuring \(\beta\): retry each failed case once. If failures were independent, a share \(q\) would fail again. The excess over \(q\) gives \(\beta\) exactly, with the formula above.
- Cost: sequential retries stop at the first success, so you pay far fewer than \(k\) attempts on average. Parallel attempts always pay \(k\), in exchange for one round of latency.
- Attempts for a target \(T\): with independent failures, \(k^* = \lceil \ln(1-T)/\ln q \rceil\). With a shared cause, a target above \(1-\beta q\) is unreachable at any \(k\).
Where each of these comes from is worked through in Derivations at the end of the page.
Interactive calculator
Set attempt quality and how correlated failures are. The curve compares what the independence math promises with what shared causes allow; the simulation runs 40 requests attempt by attempt.
Worked example: a text-to-SQL step
An analytics agent turns business questions into SQL. A checker runs each query against a test copy of the warehouse and rejects anything that errors or returns the wrong columns. On 1,000 labeled questions, one attempt passes 70% of the time.
The team allowed up to three attempts and expected \(1 - 0.3^3 = \) 97.3%. Production showed 89.9%. Retrying every failed question once explained the gap: 46% failed again, where independent failures would give 30%. Plugging that in, \(\beta = (0.46-0.3)/(1-0.6+0.3\times0.46) \approx 0.3\). Reading the failures confirmed it: about a third came from questions about tables that were never in the agent's schema context, and no retry can fix a table the model cannot see.
What each change buys
Going from three to ten attempts bought 1.1 points and tripled the worst-case cost. Making the attempts different bought 5 points for free, because sequential retries stop at the first success and still average only 1.4 attempts per question. Fixing the schema context itself, which removes the shared cause rather than working around it, is the change that eventually took the step past 95%.
Assumptions and where it breaks
- The checker is assumed perfect. A retry only happens when a failure is detected, and a passing-but-wrong answer is final. Combine with the detection rate \(d\) from M01: only detected failures get another attempt.
- \(\beta\) is not one number. It varies by input. Easy questions have a low shared-cause share; questions outside the agent's knowledge have \(\beta\) near 1. Measure it per segment when segments differ.
- Later attempts are not copies. A retry that sees the error message is a different attempt, often with higher \(p\) and lower \(\beta\). The model treats attempts as identical, so it understates well-designed retries.
- Retries have side effects. Repeating a step that sends an email, charges a card or writes a record can do it twice. Retry only idempotent steps, or attach an idempotency key.
- Parallel attempts are not free. They cost \(k\) times the tokens, consume \(k\) slots against your rate limit, and if you wait for all of them, latency is the slowest of \(k\). See M04 for the queueing cost.
How to apply it
- Measure the repeat-failure rate. Take 100+ failed cases, retry each once, and count how many fail again. Compute \(\beta = (r-q)/(1-2q+rq)\).
- Check the ceiling before adding attempts. If \(1-\beta q\) is below your target, more retries cannot get you there.
- Make retries different. Feed back the error, re-retrieve context, raise temperature, or switch to a second model. Each lowers \(\beta\).
- Attack the shared cause directly. Read the cases that fail every time; they usually point to missing context or a broken tool, and fixing that raises the ceiling itself.
- Cap attempts where the curve flattens. Two or three is typical. Make every retried step idempotent.
How to explain it to a stakeholder
"Retrying is asking the same person the same question again. It helps when they misheard, and does nothing when they don't know. So the second time, we ask differently, or we ask someone else."
Related models and patterns
For coding agents
A machine-readable summary and a reference implementation. The same spec is embedded in this page as <script type="application/json" id="model-spec">, and the whole series is listed in models.json.
id: redundancy-retries
number: M02
name: Redundancy and retries (beta-factor model)
family: reliability
answers: "How much do k retries or parallel attempts raise success, and where do they stop helping?"
formula:
independent_success: "1 - q**k, q = 1 - p"
all_fail: "b*q + (1 - b*q) * qi**k, qi = (1 - b)*q / (1 - b*q)"
ceiling: "1 - b*q"
beta_from_repeat_failures: "(r - q) / (1 - 2*q + r*q)"
expected_attempts_sequential: "sum_{j=0}^{k-1} P(first j attempts fail)"
inputs:
p: {type: float, range: [0, 1], meaning: single-attempt success}
k: {type: int, meaning: maximum attempts}
b: {type: float, range: [0, 1], meaning: share of failures with a shared cause (beta)}
r: {type: float, range: [0, 1], meaning: share of failed cases that fail again on one retry}
assumptions:
- a checker identifies failed attempts perfectly
- attempts are exchangeable (same p and beta every time)
- retried steps are idempotent
use_when:
- deciding how many retries or samples to allow
- explaining why retries plateau below target
related_patterns: [parallelization, evaluator-optimizer, fast-slow-escalation, test-first-loop]import math
def p_all_fail(p, k, beta=0.0):
"""Probability that all k attempts fail under the beta-factor model."""
q = 1 - p
if beta * q >= 1:
return 1.0
qi = (1 - beta) * q / (1 - beta * q)
return beta * q + (1 - beta * q) * qi ** k
def success(p, k, beta=0.0):
return 1 - p_all_fail(p, k, beta)
def ceiling(p, beta):
return 1 - beta * (1 - p)
def beta_from_repeat_failures(p, r):
"""r: share of failed cases that fail again when retried once."""
q = 1 - p
return (r - q) / (1 - 2 * q + r * q)
def expected_attempts(p, k, beta=0.0):
"""Sequential retries that stop at the first success."""
return sum(p_all_fail(p, j, beta) if j else 1.0 for j in range(k))
def attempts_for_target(p, target, beta=0.0, k_max=100):
for k in range(1, k_max + 1):
if success(p, k, beta) >= target:
return k
return None # unreachable: target above the ceiling
if __name__ == "__main__":
print(success(0.7, 3)) # 0.973
print(success(0.7, 3, beta=0.3)) # 0.899
print(ceiling(0.7, 0.3)) # 0.91
print(beta_from_repeat_failures(0.7, 0.4615)) # 0.30
print(expected_attempts(0.7, 3, beta=0.3)) # 1.44Derivations
For the math-curious: where each result in The math comes from. Nothing above depends on reading this.
Independent attempts: \(1-q^k\)
Let \(F_j\) be the event "attempt \(j\) fails", with \(\Pr(F_j) = q\). The task fails only if every attempt fails. If the attempts are independent, \(\Pr(F_1\cap\dots\cap F_k) = q^k\), so success is \(1-q^k\). Each extra attempt multiplies the remaining failure by \(q\): the curve rises fast at first and then flattens toward 1.
The beta-factor model and its ceiling
Model each request as facing two kinds of trouble. With probability \(\beta q\), a shared cause strikes and every attempt fails. Otherwise, attempts fail independently with some probability \(q_i\). For a single attempt to still fail with overall probability \(q\), the two parts must add up:
$$q = \beta q + (1-\beta q)\,q_i \quad\Longrightarrow\quad q_i = \frac{(1-\beta)\,q}{1-\beta q}.$$All \(k\) attempts fail if the shared cause strikes, or if it doesn't and all \(k\) independent tries fail:
$$P_{\text{all fail}} = \beta q + (1-\beta q)\,q_i^{\,k}.$$As \(k\to\infty\), \(q_i^{\,k}\to 0\) (since \(q_i<1\)), leaving \(P_{\text{all fail}}\to\beta q\) and success \(\to 1-\beta q\). Safety engineers often use the simpler approximation \(\beta q + ((1-\beta)q)^k\), which is close when \(\beta q\) is small; this page uses the exact form.
Measuring \(\beta\) from one retry of each failure
Retry every failed case once and record the share \(r\) that fails again. Under the model, that is \(\Pr(\text{both fail})/\Pr(\text{first fails})\):
$$r = \frac{\beta q + (1-\beta q)q_i^2}{q} = \beta + \frac{(1-\beta)^2 q}{1-\beta q}.$$Multiply through by \(1-\beta q\) and expand. The \(\beta^2\) terms cancel, leaving an equation that is linear in \(\beta\):
$$r - r\beta q = \beta + q - 2\beta q \quad\Longrightarrow\quad \beta = \frac{r-q}{1-2q+rq}.$$Sanity checks: if \(r = q\) (repeat failures happen at the base rate), \(\beta = 0\). If \(r = 1\) (every failure repeats), \(\beta = (1-q)/(1-q) = 1\).
Expected attempts when retrying one after another
With sequential retries you make attempt \(j+1\) only if the first \(j\) all failed. The expected number of attempts is the sum of the probabilities of reaching each attempt:
$$\mathbb{E}[\text{attempts}] = \sum_{j=0}^{k-1} \Pr(\text{first } j \text{ fail}) = 1 + \sum_{j=1}^{k-1}\big(\beta q + (1-\beta q)\,q_i^{\,j}\big).$$With \(\beta = 0\) this is the geometric sum \((1-q^k)/(1-q)\). At \(p=0.7\), \(k=3\), \(\beta=0.3\) it comes to 1.44: you allow three attempts but pay for about one and a half. In parallel mode the cost is exactly \(k\).
Attempts needed for a target
With independent failures, solve \(1-q^k \ge T\): \(k \ge \ln(1-T)/\ln q\), rounded up. With a shared cause, \(P_{\text{success}}\) is increasing in \(k\) but bounded by \(1-\beta q\), so a solution exists only when \(T < 1-\beta q\). Then
$$k^* = \left\lceil \frac{\ln\!\big((1-T-\beta q)/(1-\beta q)\big)}{\ln q_i} \right\rceil.$$References
- Mosleh, A. et al. (1998). Guidelines on Modeling Common-Cause Failures in Probabilistic Risk Assessment (NUREG/CR-5485). U.S. Nuclear Regulatory Commission. The standard reference for the beta-factor model.
- Chen, M. et al. (2021). Evaluating Large Language Models Trained on Code. Introduces pass@k, the evaluation form of \(1-(1-p)^k\).
- Brown, B. et al. (2024). Large Language Monkeys: Scaling Inference Compute with Repeated Sampling. Shows coverage rising with more samples, and how much depends on having a verifier to pick the right one.