Budgeted Retry

loop pattern · maturity: emerging · risk: medium

Failed operations are retried under an explicit budget (attempts, cost, or time) with a required diagnosis between attempts. When the budget exhausts, the loop escalates to a human with the evidence trail instead of failing silently or looping forever.

When to use

Flaky environments: network operations, test suites with intermittent failures, external API integration.

Steps

StepWhat happensVerification
AttemptRun the operation, capturing full output.Output captured verbatim.
DiagnoseClassify the failure: transient, deterministic, or environmental. Same-input retry is only justified for transient.Classification written down with the evidence that supports it.
Retry or escalateRetry (possibly modified) if budget remains and failure is plausibly transient; otherwise escalate with the trail.Budget decremented every attempt; escalation includes all diagnoses.

Specification

Verification methodSuccess criterion of the wrapped operation; the loop adds bookkeeping, not new checks.
Recovery behaviorescalate
ObservabilityAttempt count, per-attempt diagnosis, budget remaining.
InputsOperation, Budget, Escalation channel
OutputsSuccess, or a structured escalation
Risk level / maturitymedium / emerging

Failure modes

  • Retrying deterministic failures
  • Budget set so high escalation never happens
  • Diagnosis skipped under time pressure

Assessment

The unglamorous loop that separates production agents from demos. The mandatory diagnosis step is the load-bearing element; retry-without-diagnosis is just slower failure.

Go deeper