Agent failure recovery: retry without doing it twice, resume without starting over
智能体失败恢复
When one step of a multi-step agent job fails, times out or the process crashes: classify the failure, bound retries with capped backoff and jitter, make effects idempotent, resume from checkpoints and compensate what cannot finish, tested on a synthetic five-step booking job.
agent-failure-recoveryStep four timed out. Now what?
An agent books a trip in five steps: search, hold a seat, hold a hotel room, charge the card, confirm. The charge call times out. The agent does not know whether the card was charged. If it simply calls again, the customer may pay twice. If it gives up, the seat and the room stay held for nobody. If the agent’s own process crashes a moment later and is restarted, it may run the search and both holds again from scratch. And if the hotel is simply sold out, no amount of retrying will help.
Agent failure recovery restores such a job to a correct state: finish it if possible, otherwise leave nothing half-done, without repeating side effects or overloading a struggling service. These challenges predate agents; distributed systems have used the same tools for decades: timeouts, retries with backoff and jitter, idempotency keys, checkpoints, and compensating actions. What agents add is a planner that may itself repeat steps, stop too early or skip verification, which infrastructure cannot fix.
This article builds on two related articles without repeating them. Function calling derives the basic idempotency key and the expected number of duplicate effects when replies are lost. Agent orchestration derives what a checker and retries achieve when attempts are independent and how correlated failures break that. Here the subject is the recovery machinery around a whole multi-step job. Every number from code below comes from an original synthetic simulation; no model, network, payment or booking system is involved, and the fault probabilities are invented parameters.
Detect, retry, deduplicate, resume, undo
Kinds of failure. Marc Brooker’s Amazon Builders’ Library article names timeouts, retries and backoff as the three essential tools Amazon uses to keep a small percentage of failures from growing into an outage. Failures happen It distinguishes partial failures, where some percentage of requests succeed, from transient failures, where requests fail for a short period; retries help with both. Failures happen For recovery it helps to add two more classes. A permanent failure cannot be fixed by repeating the same request: AWS’s advice is that client errors (HTTP 4xx) should generally not be retried unchanged, while server errors may succeed later, though eventual consistency blurs the line. Retries and backoff And an ambiguous outcome, such as a timeout or a lost reply, means the effect may or may not have happened: the article notes that a timeout or failure does not mean side effects did not happen, and that operations whose repetition is undesirable should be idempotent so they can be retried safely. Failures happen Finally, the agent process itself can crash between steps.
Timeouts detect slow failure. AWS reports choosing a timeout by first picking an acceptable rate of false timeouts, for example 0.1%, and then using the corresponding latency percentile of the dependency, here p99.9; this needs padding when p99.9 is close to p50 and extra allowance for network latency at internet scale. Timeouts set too low can turn a small rise in latency into an outage, because every request then retries. Timeouts
Retries are selfish. The article calls retries selfish: a client spends more of the server’s time to raise its own chance of success. Under overload, retries make things worse and can delay recovery. Retries and backoff Backoff spaces retries out, but capped exponential backoff still leaves clients retrying at the capped rate forever, so Amazon’s usual answer is to limit the number of retries and handle the failure earlier. Retries and backoff Brooker’s 2015 post defines the schedules precisely. Exponential backoff and jitter With base delay b, cap c, retry index k = 0, 1, 2, …, U(a, z) a uniform draw, and s_k the sleep before retry k + 1 (with s₋₁ = b for the decorrelated rule):
These are capped exponential backoff, “Full Jitter”, “Equal Jitter” and “Decorrelated Jitter”. Summing over m waits gives the waiting budget, deterministic for plain backoff and in expectation for the two jitter rules that draw within c_k:
The practical consequence: when a job has a deadline, the number of retries should be derived from W_m and the deadline, not chosen independently.
Why jitter. Jitter adds randomness so that clients that failed together do not all retry at the same instant. Jitter The 2015 post simulated clients using optimistic concurrency on a single database row: with N contenders the total work grows like N², and capped exponential backoff alone still produces clusters of calls. Introducing OCC; Adding backoff In that simulation, with 100 contending clients, jitter cut the number of calls by more than half compared with backoff without jitter; Full and Equal Jitter used approximately the same number of calls, Decorrelated more; of the two, Equal Jitter did slightly more work than Full and took much longer; and none of them changes the N² nature of the work. Adding jitter These are AWS’s reported simulation results; we did not digitise the graphs and quote no call counts from them. For scheduled work, the Builders’ Library article prefers a consistent jitter per host, so that a problem recurs in a recognisable pattern, and AWS retries only when it observes that the dependency is healthy. Jitter; Conclusion
Retries multiply across layers. If each of L layers in a call stack makes up to r tries, a single failing request at the top can produce up to
AWS reports that a five-deep stack with three tries per layer can multiply database load 243-fold, and recommends retrying at a single point in the stack for low-cost operations. Retries and backoff AWS also reports that circuit breakers introduce modal behaviour that is hard to test and can add recovery time; it limits retries locally with a token bucket (retry freely while tokens remain, then at a fixed rate), a mechanism it says was added to the AWS SDK in 2016. Retries and backoff These are one organisation’s operational reports, not universal laws.
Idempotency keys as a contract. The basic mechanism (store a key with the result, replay the result on retry) is in function calling. What a multi-step agent also needs is the contract around it. The IETF Internet-Draft on an Idempotency-Key HTTP header field (revision 07, October 2025, a work in progress rather than an RFC) aims to make non-idempotent methods such as POST and PATCH fault-tolerant; it recalls that under RFC 9110 OPTIONS, HEAD, GET, PUT and DELETE are idempotent and POST and PATCH are not. Abstract, §1 A key must be unique and must not be reused with a different request payload; a UUID or similar random identifier is recommended; the resource may expire keys and should publish its expiry policy. §2.2–2.3 The resource may combine the key with a fingerprint of the payload: a checksum over all or selected fields, field matching, or a digest or signature. §2.4 Enforcement has five cases: a first-time key is processed normally; a retry after the original completed should get the stored result, success or error; a retry while the original is still processing should get a 409 Conflict; a missing required key gets 400; and a reused key with a different payload gets 422. §2.6–2.7 On security, low-entropy keys let an attacker guess other clients’ keys and read their cached responses, so the draft recommends a published key format, validation, and a lookup key that combines the client’s key with client-specific attributes known to the resource. §5 Even with all of this, a key deduplicates at one resource while the key is stored. Expiry, a changed payload or a different resource breaks it; it is not exactly-once execution in general.
Checkpoints and durable handles. A crash should not force a job to redo finished steps. Saving the index of the next step to run (a checkpoint) lets a restarted process resume. On the tool side, MCP 2025-11-25 added experimental tasks: durable state machines that wrap a request and carry a task id generated by the receiver, so a client can poll with tasks/get and fetch a deferred result with tasks/result. Terminal states (completed, failed, cancelled) never change. Receivers must report createdAt, lastUpdatedAt and the actual ttl, may delete a task after its ttl, and may suggest a pollInterval. Tasks A cancelled task must stay cancelled even if the underlying work later completes or fails, and requestors should not rely on cancelled tasks being retained; they should fetch what they need first. Tasks So a durable handle survives a lost connection, but not indefinitely.
Compensation: sagas. Garcia-Molina and Salem (SIGMOD 1987) define a saga as a long-lived transaction written as a sequence of transactions T₁ … Tₙ that may interleave with other transactions. Each Tᵢ has a compensating transaction Cᵢ that undoes it semantically, not by restoring the old state. The system guarantees that one of two sequences executes:
Other transactions may see the partial results, and they are not notified when compensation runs. p. 250 The paper’s airline example shows why compensation must be semantic: if Tᵢ reserves a seat, Cᵢ cancels it by decrementing the reservation count, not by writing back the old count, because other transactions may have changed it in between. p. 250 Running compensations is backward recovery. Forward recovery instead completes the missing transactions from a save point, which needs reliable code for the remaining steps; with save points, valid executions include partial compensation followed by re-execution, such as T₁ T₂ C₂ T₂ T₃ …. After a crash, a saga without an end record is either compensated or restarted at its last save point. pp. 252–254 Compensation is not rollback: the intermediate state was visible, and some effects, such as a sent email or released information, have no inverse at all.
Failures above the infrastructure. Cemri and colleagues (arXiv v3, October 2025; NeurIPS 2025 Datasets and Benchmarks track) annotated 1642 execution traces from 7 multi-agent frameworks and proposed MAST, a taxonomy of 14 failure modes in 3 categories (system design, inter-agent misalignment, task verification), with inter-annotator agreement κ = 0.88. Abstract; Figure 1 Over those traces, the reported prevalence of some modes is: step repetition 15.7%, reasoning–action mismatch 13.2%, unawareness of termination conditions 12.4%, incorrect verification 9.1%, no or incomplete verification 8.2%, premature termination 6.2%. Figure 1; pp. 7–8 By category, Figure 1 gives system design 44.2%, inter-agent misalignment 32.3% and task verification 23.5%; a separate figure over a subset of 210 traces shows 41.8%, 36.9% and 21.3%, so the two should not be mixed. Figure 1; Figure 4 These are frequencies of failure modes in annotated traces of specific frameworks and models. They are not production failure rates and not the effect of any fix. The authors also note that standardized message formats such as MCP and A2A do not remove misalignment failures, which occur even when agents within one framework talk in natural language. p. 8 And one mode, conversation reset, is defined as an unwarranted restart of a dialogue that may lose context and progress: a case where “recover by restarting” is itself the failure. Appendix A
A toy model to check the simulation. For the booking job below, suppose each try of a step fails transiently before any effect with probability p_t, commits the effect but loses the reply with probability p_ℓ, and a step allows at most m tries; a job of n steps also fails permanently with probability p_s. A step exhausts its tries with probability
because with an idempotency key a lost reply is followed by a replay of the stored result on the next try, so only a lost reply on the last try still fails the step. Ignoring crashes,
This model is ours, built only to check the simulation’s success rates.
Four recovery policies on the same faults
The program has four parts. Part 1 computes backoff schedules with b = 0.1 s and c = 2.0 s. Part 2 prints retry amplification. Part 3 is our own contention toy: 50 clients share one slotted resource, and a slot succeeds only if exactly one client tries in it; after a failure a client waits according to its strategy (base 1 slot, cap 64 slots) plus network noise drawn uniformly from 0 to 3 slots, and gives up after 15 tries; results are means over 20 seeds. It is not AWS’s simulator. Part 4 runs 5000 synthetic five-step booking jobs (search, hold_seat, hold_room, charge, confirm) under four cumulative policies, using common random numbers: the same (job, step, call index) gets the same draw under every policy, so differences come from the policies and not from luck. Faults are p_t = 0.15, p_ℓ = 0.05, a crash after a step with probability 0.05 and a sold-out room with probability 0.05, which is permanent; each step allows 4 tries. Keys are derived from (job, step), so they survive restarts.
"""Synthetic failure-recovery simulations: backoff schedules, retry amplification,
contention with and without jitter, and a five-step booking job under four recovery
policies. Original toy code: no model, no network, no real payment or booking."""
import heapq
import math
import random
# ---------------------------------------------------------------- 1. schedules
BASE, CAP, TRIES = 0.1, 2.0, 6
caps = [min(CAP, BASE * 2 ** k) for k in range(TRIES)]
print('== 1. Backoff schedule, base 0.1 s, cap 2.0 s, 6 waits ==')
print('capped exponential waits:', [round(c, 2) for c in caps], 'sum', round(sum(caps), 2))
print('expected sum, full jitter U(0, c_k): ', round(sum(c / 2 for c in caps), 3))
print('expected sum, equal jitter c_k/2+U(0,c_k/2):', round(sum(0.75 * c for c in caps), 3))
rng = random.Random(7)
full = [rng.uniform(0, c) for c in caps]
prev, deco = BASE, []
for _ in range(TRIES):
prev = min(CAP, rng.uniform(BASE, prev * 3))
deco.append(prev)
print('one full-jitter draw (seed 7):', [round(x, 3) for x in full], 'sum', round(sum(full), 3))
print('one decorrelated draw: ', [round(x, 3) for x in deco], 'sum', round(sum(deco), 3))
# ---------------------------------------------------------------- 2. amplification
print('\n== 2. Retry amplification: 3 attempts at every layer ==')
for layers in range(1, 6):
print(f'{layers} layer(s): up to {3 ** layers} calls reach the bottom service')
# ---------------------------------------------------------------- 3. contention
def contention(strategy, n=50, max_tries=15, seed=0):
"""Slotted shared resource: a slot succeeds only if exactly one client tries in it.
After a failure a client waits per strategy, plus U(0,3) slots of network noise."""
r = random.Random(seed)
heap = [(0, c) for c in range(n)]
tries = [0] * n
last_sleep = [1.0] * n
calls = done = gave_up = 0
finish = 0
while heap:
slot = heap[0][0]
group = []
while heap and heap[0][0] == slot:
group.append(heapq.heappop(heap)[1])
calls += len(group)
if len(group) == 1:
done += 1
finish = slot
continue
for c in group:
tries[c] += 1
if tries[c] >= max_tries:
gave_up += 1
finish = slot
continue
k = tries[c] - 1
ceiling = min(64.0, 1.0 * 2 ** k)
if strategy == 'immediate':
wait = 0.0
elif strategy == 'exponential':
wait = ceiling
elif strategy == 'full jitter':
wait = r.uniform(0, ceiling)
elif strategy == 'equal jitter':
wait = ceiling / 2 + r.uniform(0, ceiling / 2)
else:
wait = min(64.0, r.uniform(1.0, last_sleep[c] * 3))
last_sleep[c] = wait
heapq.heappush(heap, (slot + 1 + int(wait + 3 * r.random()), c))
return calls, done, gave_up, finish
print('\n== 3. 50 clients contend for one slot-shared resource (mean of 20 seeds) ==')
print(f'{"strategy":<14}{"calls":>8}{"succeeded":>11}{"gave up":>9}{"slots until all settled":>25}')
for s in ['immediate', 'exponential', 'full jitter', 'equal jitter', 'decorrelated']:
runs = [contention(s, seed=i) for i in range(20)]
m = [sum(x[j] for x in runs) / 20 for j in range(4)]
print(f'{s:<14}{m[0]:>8.1f}{m[1]:>11.1f}{m[2]:>9.1f}{m[3]:>25.1f}')
# ---------------------------------------------------------------- 4. booking job
STEPS = ['search', 'hold_seat', 'hold_room', 'charge', 'confirm']
EFFECT = {'hold_seat', 'hold_room', 'charge', 'confirm'}
UNDO = {'hold_seat': 'release_seat', 'hold_room': 'release_room', 'charge': 'refund'}
P_TRANSIENT, P_LOST_REPLY, P_CRASH, P_SOLD_OUT, MAX_TRIES = 0.15, 0.05, 0.05, 0.05, 4
def draw(*key):
"""Common random numbers: the same (job, step, call index) gives the same draw in every policy."""
return random.Random(repr(key)).random()
def run_job(job, keys, checkpoint, compensate):
effects = {} # step -> number of real side effects applied
store = {} # idempotency key -> stored result
calls = {s: 0 for s in STEPS}
reached = {s: 0 for s in STEPS}
sold_out = draw(job, 'sold') < P_SOLD_OUT
saved = 0 # checkpoint: index of the next step to run
restarts = 0
total_calls = 0
while True:
start = saved if checkpoint else 0
crashed = failed = False
for i in range(start, len(STEPS)):
step = STEPS[i]
ok = False
for _ in range(MAX_TRIES):
calls[step] += 1
total_calls += 1
key = (job, step)
if keys and key in store:
ok = True # replay stored result, no new effect
break
if step == 'hold_room' and sold_out:
failed = True # permanent: do not retry
break
u = draw(job, step, calls[step])
if u < P_TRANSIENT:
continue # failed before any effect
if step in EFFECT:
effects[step] = effects.get(step, 0) + 1
if keys:
store[key] = 'done'
if u < P_TRANSIENT + P_LOST_REPLY:
continue # effect happened, reply lost
ok = True
break
if failed or not ok:
failed = True
break
saved = i + 1
reached[step] += 1
if i < len(STEPS) - 1 and draw(job, 'crash', step, reached[step]) < P_CRASH:
crashed = True
break
if crashed:
restarts += 1
continue
break
undone = 0
if failed and compensate:
for step in reversed(STEPS):
if step in UNDO and effects.get(step, 0) > 0:
total_calls += 1
undone += effects[step]
effects[step] = 0
success = not failed
duplicates = sum(max(0, n - 1) for n in effects.values())
leaked = 0 if success else sum(effects.get(s, 0) for s in UNDO)
return success, duplicates, leaked, total_calls, restarts, undone
POLICIES = [('A retry, restart from step 1', False, False, False),
('B + idempotency keys', True, False, False),
('C + checkpoint resume', True, True, False),
('D + saga compensation', True, True, True)]
JOBS = 5000
print(f'\n== 4. Five-step booking job, {JOBS} synthetic jobs, same fault draws for every policy ==')
print(f'faults: transient {P_TRANSIENT}, reply lost after effect {P_LOST_REPLY}, crash after a step '
f'{P_CRASH}, room sold out {P_SOLD_OUT}; at most {MAX_TRIES} tries per step')
print(f'{"policy":<31}{"success":>8}{"dup effects":>12}{"leaked":>8}{"calls/job":>10}{"restarts":>9}{"undone":>8}')
for name, keys, ckpt, comp in POLICIES:
res = [run_job(j, keys, ckpt, comp) for j in range(JOBS)]
succ = sum(r[0] for r in res) / JOBS
dup = sum(r[1] for r in res)
leak = sum(r[2] for r in res)
calls = sum(r[3] for r in res) / JOBS
rest = sum(r[4] for r in res)
undone = sum(r[5] for r in res)
print(f'{name:<31}{succ:>8.3f}{dup:>12d}{leak:>8d}{calls:>10.3f}{rest:>9d}{undone:>8d}')
q_plain = (P_TRANSIENT + P_LOST_REPLY) ** MAX_TRIES
q_keyed = P_TRANSIENT ** MAX_TRIES + P_TRANSIENT ** (MAX_TRIES - 1) * P_LOST_REPLY
print('\nstep fails all tries, no keys (0.20^4): ', round(q_plain, 6))
print('step fails all tries, with keys (0.15^4+0.15^3*0.05):', round(q_keyed, 6))
print('predicted job success, no keys 0.95*(1-q)^5:', round((1 - P_SOLD_OUT) * (1 - q_plain) ** 5, 4))
print('predicted job success, with keys 0.95*(1-q)^5:', round((1 - P_SOLD_OUT) * (1 - q_keyed) ** 5, 4))
print(f'binomial standard error at p=0.946, n={JOBS}:', round(math.sqrt(0.946 * 0.054 / JOBS), 4))
Part 1: schedules. The capped waits are 0.1, 0.2, 0.4, 0.8, 1.6 and 2.0 s, so W₆ = 5.1 s. The expected total sleep is 2.55 s under full jitter and 3.825 s under equal jitter. One seeded full-jitter draw sums to 1.97 s and one decorrelated draw to 0.932 s; these single draws only illustrate the spread.
Part 2: amplification. With three tries at every layer, up to 3, 9, 27, 81 and 243 calls reach the bottom service for one to five layers, the 243 matching AWS’s five-layer example.
Part 3: contention.| Strategy | Calls | Succeeded | Gave up | Slots until all settled |
|---|---|---|---|---|
| immediate retry | 749.9 | 1.1 | 49.0 | 34.4 |
| exponential, no jitter | 680.9 | 14.0 | 36.0 | 606.9 |
| full jitter | 441.0 | 50.0 | 0.0 | 200.3 |
| equal jitter | 420.1 | 50.0 | 0.0 | 257.4 |
| decorrelated jitter | 509.4 | 46.6 | 3.4 | 249.1 |
Immediate retry is close to the maximum of 750 calls (50 clients × 15 tries): nearly everyone collides every time and gives up quickly. Exponential backoff without jitter keeps the clients synchronised, since clients that collided together wait the same time and collide again, so most still exhaust their tries, only later. Both full and equal jitter let all 50 clients succeed with far fewer calls. In this toy, equal jitter makes slightly fewer calls than full jitter but takes longer to settle, and decorrelated jitter lets 3.4 clients give up on average. The direction of the main result, that jitter rather than backoff alone breaks up collisions, agrees with the 2015 post. The detail does not fully agree: the post reports Full and Equal Jitter using approximately the same number of calls, with Equal Jitter doing slightly more work, whereas here equal jitter uses fewer calls than full jitter. Our model is different and much cruder (slotted time, success only for a lone caller, a hard limit of 15 tries), so this table neither reproduces nor checks AWS’s figures.
Part 4: the booking job.| Policy | Success | Duplicate effects | Leaked effects | Calls per job | Restarts | Undone |
|---|---|---|---|---|---|---|
| A retry, restart from step 1 | 0.940 | 2697 | 362 | 6.660 | 1040 | 0 |
| B + idempotency keys | 0.943 | 0 | 290 | 6.491 | 1042 | 0 |
| C + checkpoint resume | 0.943 | 0 | 290 | 5.989 | 928 | 0 |
| D + saga compensation | 0.943 | 0 | 0 | 6.047 | 928 | 290 |
A “duplicate effect” is a hold, charge or confirmation applied more than once in a job; a “leaked effect” is a hold or charge left standing in a job that failed.
- Keys remove every duplicate side effect, 2697 → 0. Under policy A duplicates arise both from lost replies, where the effect committed and the retry commits it again, and from crash restarts that re-run completed steps.
- Checkpoints cut calls per job from 6.491 to 5.989, because finished steps are not re-run after a crash. They do not change the success rate. Restarts also fall, from 1042 to 928, because restarting from step 1 passes more step boundaries, each with its own crash draw.
- Compensation does not change the success rate either. It turns the 290 holds and charges left behind in failed jobs into 290 undone effects, at a cost of 0.058 extra calls per job (290/5000).
- Success is bounded by the 5% of jobs whose room is sold out, which no retry can fix.
The toy model checks the success column. Without keys, q_plain = 0.2⁴ = 0.0016; with keys, q_key = 0.15⁴ + 0.15³ × 0.05 = 0.000675. The predicted job success is 0.95 × (1 − q)⁵ = 0.9424 without keys and 0.9468 with keys, against simulated 0.940 and 0.943. The binomial standard error at n = 5000 is about 0.0032, so both lie within about 1.2 standard errors. For policy A the prediction is only approximate, since crash restarts re-run steps and give them extra chances to fail.
What recovery machinery cannot do
The simulation is generous to recovery. Compensations always succeed; crashes happen only between steps, never in the middle of one; the confirm step has no compensation, which is harmless only because it is last; part 4 has no clock, so deadlines and backoff waits play no role there; and the table of stored results never expires. Real compensations fail and need their own retries, a crash between committing an effect and recording it in the key store reopens the duplicate problem unless both are written together, and expired keys turn late retries back into new requests.
More fundamentally, the four policies only handle failures the infrastructure can see. An agent that repeats a finished step because it lost track of its progress, stops before the task is done, or accepts a wrong answer without checking will do so under every policy in the table. MAST’s frequencies say such modes are common in the traces it annotated, but they are not intervention effects: nothing in them says that adding checkpoints or keys would remove a given percentage of failures. Steps that cannot be undone, such as sending a message or releasing information, need a different treatment altogether: put them last, put them behind explicit confirmation, and send them at most once.
Choose the recovery for the failure
-
An agent calls charge_card and gets a timeout. List three possibilities for the server’s state and say what a plain retry does in each.
Answer: (a) The request never arrived or failed before any effect: a retry is exactly what you want. (b) The charge committed and only the reply was lost: a plain retry charges twice. (c) The charge is still in progress: a plain retry may run concurrently and also double-charge. With an idempotency key, case (b) returns the stored result, and case (c) should get 409 Conflict under the draft, telling the client to wait rather than send something else.
-
Base 0.2 s, cap 5 s, up to 7 waits. (a) List the capped waits and their sum. (b) What is the expected total sleep under full jitter and under equal jitter? (c) With a user-facing deadline of 10 s and ignoring call time, how many waits fit in the worst case, where every wait takes its full capped value?
Answer: (a) 0.2, 0.4, 0.8, 1.6, 3.2, 5, 5, summing to 16.2 s. (b) Full jitter: 8.1 s; equal jitter: 12.15 s. (c) Cumulative worst-case totals are 0.2, 0.6, 1.4, 3.0, 6.2 and 11.2 s, so only 5 waits fit (6.2 ≤ 10 < 11.2). The retry count should be derived from the deadline, not chosen independently.
-
A tool call passes through agent runtime → MCP client → MCP server → HTTP API → database, and each of the first four layers tries up to 3 times. What is the worst-case number of calls at the database? What if only the agent runtime retries (3 tries) and the others try once?
Answer: 3⁴ = 81 calls; with a single retrying layer, at most 3. This is the reason to retry at one point in the stack.
-
(a) A client reuses idempotency key K for a second, different booking. What should the server answer under the draft, and why would silently replaying the first receipt be dangerous? (b) The compensation for hold_seat is written as “set seats_available back to the value read before the hold”. Construct an interleaving in which this corrupts the data.
Answer: (a) 422 Unprocessable Content: the fingerprint differs, so this is not a retry. Replaying would tell the user that the second booking succeeded when it never ran. (b) Seats = 10. Saga A holds one (10 → 9) and remembers 10. Saga B holds one (9 → 8). A fails and “compensates” by writing 10: B’s hold has vanished and the count is wrong; it should be 9. Compensation must be a semantic inverse, releasing one seat (8 → 9), exactly as in the airline example of the sagas paper.
-
For each step, choose among retry with a key, checkpoint and resume, compensation, or asking a human before acting: (a) re-running a deterministic test suite in a sandbox; (b) creating a cloud virtual machine that costs money per hour; (c) sending an email to a customer; (d) a 40-minute data export through a tool server that supports MCP tasks.
Answer: (a) A plain retry is safe because there is no external side effect; checkpointing finished test shards saves time. (b) Retry only with an idempotency key or client token, and give the step a compensation (delete the machine) for backward recovery. (c) It cannot be compensated, since an apology is a new message, not an undo: put it last, behind confirmation, and send it at most once with a key. (d) Use a task-augmented request and poll with the task id, so a dropped connection does not lose the work; remember that tasks are experimental in 2025-11-25 and may be deleted after their ttl.
-
A blog post says: “MAST shows 15.7% of multi-agent failures are step repetition, so adding checkpoints would remove 15.7% of failures.” Is that supported?
Answer: No. 15.7% is the prevalence of a failure mode across MAST’s 1642 annotated traces, not the effect size of any intervention. Step repetition in MAST is an agent behaviour, redoing finished steps without need, not a crash-recovery problem; checkpoints help when a process restarts and may be unrelated to why an agent repeats itself. Any claim about the effect of a fix needs its own experiment.
Sources and open problems
We read the full Builders’ Library article on timeouts, retries and backoff (published December 2019) but none of the SDK pages it links. Builders’ Library We read the 2015 post’s text and its four formula images; its graphs were not digitised and its simulator code was not read. AWS blog Of the Idempotency-Key draft we read the abstract, §1, §2.1–2.7 and §5; it is revision 07 of a work in progress, and later revisions are not used. Internet-Draft -07 The sagas paper was read as a scan with poor OCR, pages 250 and 252–254 only, and nothing is quoted from it. Sagas Of the MCP tasks page we read the introduction, the lifecycle, ttl, result and cancellation rules, and the field definitions, not the message-flow examples or error sections. MCP tasks Of the MAST paper we read the abstract, the Figure 1 caption, the results on pages 7–8 and the Appendix A definitions, not the methods, the validation of its automated judge or its intervention experiments. MAST
Open problems are mostly about the boundary between infrastructure and agent. How should an agent runtime decide that a failure is permanent rather than transient when the tool returns only text? Where in a stack of agent runtime, protocol client, tool server and API should the single retrying layer sit? How should compensations be written and tested for tools that a third party owns? And how can failures such as step repetition or premature termination be detected from a trace, so that recovery can respond to them rather than only to crashes? A useful report on a recovery design states the failure classes it handles, its timeout and retry budget, where keys are scoped and when they expire, which steps have compensations, and which steps cannot be undone at all.
Make a prediction, then check
In the example's booking job, what did adding checkpoint resume (policy C) change relative to idempotency keys alone (policy B)?
Learning objectives
- Classify failures as transient, permanent, ambiguous or process crash, and choose retry, stop, idempotency-key replay or checkpoint resume for each.
- Compute capped exponential backoff budgets and multi-layer retry amplification, and explain what jitter, saga compensation and checkpoints each reduce.
Prerequisites & connections
Explore related knowledge →References
- Timeouts, retries, and backoff with jitter — Amazon Builders' Library
Marc Brooker · 2019 - Exponential Backoff And Jitter — AWS Architecture Blog
Marc Brooker · 2015 - The Idempotency-Key HTTP Header Field — draft-ietf-httpapi-idempotency-key-header-07
J. Jena; S. Dalal · 2025 - Sagas
Hector Garcia-Molina; Kenneth Salem · 1987 - Model Context Protocol Specification 2025-11-25 — Tasks (experimental), pinned commit
Model Context Protocol contributors · 2025 - Why Do Multi-Agent LLM Systems Fail? — arXiv v3
Mert Cemri; Melissa Z. Pan; Shuyi Yang; Lakshya A Agrawal; Bhavya Chopra; Rishabh Tiwari; Kurt Keutzer; Aditya Parameswaran; Dan Klein; Kannan Ramchandran; Matei Zaharia; Joseph E. Gonzalez; Ion Stoica · 2025
Version1 · Editorial status: Recorded technical checks completed
View technical check record (AI)
Claude · 2026-12-03 · Independent AI check (Claude subagent, not the author; not a human or expert review). Gemini-app style edits logged in gemini-edits-016a.json were applied to the opening sections before this check; research was done by a separate research subagent (facts.md) and the prose by a writer subagent. I ran example.py with python3 and diffed it against example.stdout.txt (identical), confirmed the python block in en.mdx and zh.mdx is byte-identical to example.py, and matched every quoted number (schedule 5.1/2.55/3.825, single draws 1.97/0.932, 3..243 amplification, the contention table, the four-policy table, 0.058 = 290/5000, q_plain 0.0016, q_key 0.000675, predictions 0.9424/0.9468, SE 0.0032 and the 0.75 and 1.19 standard-error gaps). I re-derived the backoff formulas, the expected sums W/2 and 3W/4, r^L, the keyed exhaustion probability and the exercise answers (16.2, 8.1, 12.15, five waits, 81, the seat interleaving). I re-fetched the 2015 AWS Architecture blog post (dated 2015-03-04; text only, formula images matched against the standard definitions), the Builders' Library article (published Dec 5, 2019; checked three tools, partial/transient, 0.1%/p99.9 and padding, selfish retries, capped backoff, 243x, single retry point, circuit breakers, 2016 token bucket, 4xx guidance, consistent per-host jitter, retry only when healthy), the Idempotency-Key Internet-Draft -07 (15 October 2025, an Internet-Draft, not an RFC; abstract, section 1, 2.2-2.7 and 5; I confirmed -08 expires 25 April 2027, so it falls after the 2026-09-04 cutoff and is correctly not used), the sagas PDF (pdftotext of the scan; p. 250 definition, semantic compensation, airline example and no-notification guarantee, and save-point recovery text), the MCP tasks page at commit 1b40699 (experimental status, receiver-generated ids, status rules, createdAt/lastUpdatedAt/ttl/pollInterval, cancellation retention) and the MAST arXiv v3 PDF (26 Oct 2025; abstract, Figure 1, pp. 7-8, Figure 4 caption, Appendix A conversation reset, the MCP/A2A paragraph). The article correctly states that its own contention toy agrees with the 2015 post on direction but not on the Full-versus-Equal call count, and frames MAST percentages as failure-mode frequencies in annotated traces, not fix effects. I did not read the AWS simulator code, the MAST methods or intervention appendices, or sagas pages other than 250 and 252-254. I compared zh and en section by section and checked data.json IDs against src/data/catalogue.txt and the quiz answer. The Gemini edits changed wording only; no fact, hedge or attribution changed.
- Program output matches example.stdout.txt, both code blocks are byte-identical to example.py, and all quoted numbers, toy-model predictions and standard errors were recomputed.
- The AWS backoff formulas (capped exponential, Full, Equal, Decorrelated Jitter) match the 2015 post; the article states plainly that its own contention toy disagrees with the post on Full versus Equal call counts.
- The Idempotency-Key draft is labelled revision 07, a work-in-progress Internet-Draft and not an RFC; revision 08 is after the fact cutoff and is not used.
- The saga definitions (semantic compensation, the two execution sequences, visible partial results, forward and backward recovery) match pp. 250 and 252–254.
- MAST percentages are framed as failure-mode frequencies in annotated traces, not fix effects; category percentages now use Figure 1 (1642 traces).
- Gemini style edits changed wording only, not facts, hedges or attributions; zh and en still agree.
Source locations checked:
- Timeouts, retries, and backoff with jitter — Amazon Builders' Library · Fetched the aws.amazon.com Builders' Library URL (301 to builder.aws.com) and read the whole article text: header 'Published Dec 5, 2019'; sections Introduction/Failures Happen (paras 1–5), Timeouts (paras 1–6 incl. 0.1% / p99.9, padding, SO_RCVTIMEO pitfall, 20 ms anecdote), Retries and backoff (selfish retries, capped exponential backoff, limiting retries, five layers × 3 tries = 243×, retry at a single point, token bucket since 2016 vs circuit breakers, idempotency, 4xx vs 5xx), Jitter (3 paras incl. consistent per-host jitter), Conclusion. Linked pages (SDK retry docs, token bucket docs) NOT read.
- Exponential Backoff And Jitter — AWS Architecture Blog · Read full HTML text and viewed the formula images blog-figure-3 (capped exponential), -6 (Full Jitter), -10 (Equal Jitter), -11 (Decorrelated Jitter). Checked: OCC model with 10 ms mean delay, N² work, backoff alone still clusters, '100 contending clients … call count by more than half', Full ≈ Equal in calls, Decorrelated more, Equal slower, N² unchanged. Graph images (figures 1–2, 4–5, 7–9, 12–13) not digitised; aws-arch-backoff-simulator code NOT read.
- The Idempotency-Key HTTP Header Field — draft-ietf-httpapi-idempotency-key-header-07 · Plain-text draft -07 (dated 15 October 2025, expires 18 April 2026), lines 1–372 and 589–632: Abstract, §1 (RFC 9110 idempotent methods; timeout uncertainty), §1.1, §2–2.7 (Item Structured Header String; unique, not reused with a different payload; UUID recommended; expiry policy; fingerprint options; client and resource responsibilities; enforcement first-time/retry/concurrent; 400 missing key, 422 reused key with different payload, 409 concurrent; clients must correct requests except 409), §5 security (injection, low-entropy key leaks, composite lookup key). §3 IANA, §4 implementation status, §6 examples and references NOT read. Revision list from the IETF datatracker API: -07 2025-10-15, -08 2026-10-22.
- Sagas · pdftotext of the 11-page scan; PDF p. 1 = proceedings p. 249 (ACM 1987 notice). Read PDF p. 2 (p. 250: compensating transaction C_i semantically undoes T_i, airline seat example, guarantee T1…Tn or T1…Tj Cj…C1, partial results visible, no notification), PDF p. 4 (p. 252: abort-transaction/abort-saga/end-saga commands, save points, sequences like T1 T2 C2 T2 …), PDF pp. 5–6 (pp. 253–254: backward vs forward recovery, SEC log handling after crash, forward recovery needs save point and code for missing transactions). OCR is poor (the j<n bound is garbled; the intended condition 0≤j<n is read from context). Sections 7 onward NOT read.
- Model Context Protocol Specification 2025-11-25 — Tasks (experimental), pinned commit · Raw MDX at commit 1b406997d2bf55a6801bbbaf601a24763a6f5569: lines 1–32, 386–500, 700–722 (experimental since 2025-11-25; durable state machines; receiver-generated string ids; start in working; allowed transitions; terminal states fixed; createdAt/lastUpdatedAt/ttl/pollInterval; deletion after ttl; tasks/result blocks until terminal and returns exactly the underlying result; cancel rejects terminal tasks with −32602; cancelled stays cancelled). Lines 33–385 (capability JSON, message examples), 500–699 (flows) and 757–900 (errors, security) NOT read.
- Why Do Multi-Agent LLM Systems Fail? — arXiv v3 · arXiv PDF v3 (47 pages) via pdftotext: p. 1 abstract (1600+ traces, 7 frameworks, 150 traces for taxonomy, κ = 0.88, 14 modes in 3 categories), p. 2 Figure 1 caption (percentages over 1642 traces), p. 7–8 section 4 (FC1–FC3 with per-mode percentages; MCP/A2A paragraph; Figure 4 category totals 41.8/36.9/21.3 are over 210 traces only, so the article uses Figure 1 category totals 44.2/32.3/23.5 (checker correction); '+15.6%' and '+9.4%' intervention mentions not used), pp. 17–18 Appendix A definitions. Submission history from the arXiv abs page: v1 17 Mar 2025, v3 26 Oct 2025. Methods (sections 3, LLM-judge), Appendix H interventions and remaining appendices NOT read.
Related topics