Failure recovery · 3 min read

Retrying an AI Request Is Not an Error-Handling Strategy

What changed on 64 conditional retries, and what evidence a worker needs before another attempt.

Observed · conditional retries. Improved — 6. Unchanged category — 56. Regressed — 2.

A red test invites a cheap response. Put the same task back in the queue and give the model another turn. That can help if the first failure was transient. It can also spend a second inference budget reproducing a completely deterministic mistake, or replace a partly correct answer with a worse one.

I classified the outcomes of 64 conditional retries in my exploratory local inference study. Six improved, 56 stayed in the same outcome category, and two regressed. An unchanged category can contain a different answer. The count describes a move between categories, not a byte-for-byte comparison of generated text. These were selected retries, so six out of 64 is not a success probability for a new coding assignment.

Read the evidence that accompanies the failure

Consider a worker asked to return a JSON object with an integer version. The transport delivers a complete response and the parser accepts it. A schema check rejects the string "2" in the version field. The worker already has access to the information it needs. Sending the validator’s error and the offending field makes a narrowly targeted repair possible. A scheduler timeout before any artifact arrived would leave a different set of options.

match failure.kind:
    case "timeout":
        reschedule(task)
    case "contract_violation":
        repair(task, validation_errors)
    case "context_overflow":
        reduce_context(task)
    case "ambiguous_requirement":
        request_human_decision(task)

I would read the timeout branch carefully before implementing this sketch. A local generation that produced no external effect can be rescheduled within a deadline. A timeout after sending a write request leaves its outcome unknown. Check the request identifier or receipt before repeating that operation. The location of the timeout matters as much as the label on the exception.

Change one condition on purpose

For a context overflow, identify which portion of the assembled request consumed the budget. A useful second attempt might replace repetitive history with a short summary while retaining the exact acceptance criteria and failing input. For an ambiguous assignment, write down the two plausible interpretations and the observable behavior that differs. The cheapest way forward may be one question to the requester.

For either branch I want the attempt record to say what changed. It can be as short as “preserved the schema, supplied the failing example, allowed one repair.” Save the first candidate and its fixture results. Compare the new candidate on the same fixtures before promoting it. That last step is easy to skip when only the latest answer is visible, and it is precisely what makes a regression observable.

Give the queue a stopping condition

A Fredrin-style self-healing worker would need a retry budget, an elapsed-time budget, and an owner for unresolved work. When either budget expires, hand off the best verified artifact with the remaining failure. A successful repair should close the loop by recording which intervention preceded acceptance. The next investigation can then ask whether a particular class of intervention helped a particular task family.

The study counts motivate that instrumentation. They do not tell us which intervention caused an improvement, because the retry outcomes alone do not supply a controlled comparison. To test a policy, freeze the failed inputs, compare a plain retry with a targeted repair, and score both using the same rubric and budget. That would turn a scheduler rule into an engineering decision someone else can reproduce.

Supporting diagrams (4)
Illustrative schema error. field      version. expected   integer. received   string "2". next       send field error to worker.
Pass the failure into repair
Proposed routing. Schema violation — targeted repair. Context overflow — repack input. Ambiguous goal — ask requester. Timeout after write — look up receipt.
Choose a recovery by cause
Proposed comparison. Before — Preserve candidate and fixtures. Repair — Record the changed condition. After — Score both on the same rubric.
Keep the first candidate
Proposed handoff. Keep — Best verified candidate. Attach — Remaining error and spent budget. Route — Owner for unresolved work.
When an attempt budget expires
Debugger workspaceDiagnose a failed attempt ↗