Routing, Fallbacks, and Graceful Degradation › Deterministic Fallbacks and Provider Failover
Language AI HandbookAll chapters A retry attempts the same operation again. A fallback takes a different path. With a fixed attempt budget, retry only when the failure might be transient and another attempt fits the budget. Google SRE's guidance on cascading failures recommends limiting retries, spreading them with randomized exponential backoff, and checking the remaining deadline before starting another stage. A timeout is an observation about waiting. For operations with side effects, require a verified idempotency guarantee before attempting them again.
In the acceptance benchmark we already have a candidate for every tier. In an actual request, the application can encounter an unavailable dependency before there is any candidate to score. The router still needs to distinguish a known unavailable route, which it can skip, from a call that consumed budget before failing. Record the reason in the trace so causes such as an eligibility restriction, an outage, and a low-confidence answer do not get merged in evaluation.
A deterministic fallback can be a stored message or an extract from an approved source. A fallback to another model retains all of the ordinary requirements, including which data that model may receive. The next code example also demonstrates a budget for attempts even though the in-memory fixture makes every branch fast. A remote implementation would combine its attempt count with a deadline and apply a separate policy for retries.
The next fixtures use a finite attempt limit and no actual delays. Each tier has a scripted policy-eligibility flag, an availability flag, and an optional candidate. An eligible, available tier whose candidate is absent consumes one attempt. An ineligible or unavailable tier consumes none. We return at most one accepted candidate and record its tier.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!