Route production failures by class
Choose a retry, degradation and failover policy that fits the failure, deadline and destination's capabilities.
Scenario
Dispatchers use a live translation service to read rail maintenance bulletins. One route is rate-limited, and the runbook sends every incomplete job to the same backup. Some jobs return a headline with the body missing. A dispatcher can always open the source bulletin, and every translated restriction must retain its source reference.
Explanation
Decide what happened before spending another attempt. An HTTP error describes request processing. The Messages API's stop_reason describes how a response ended, so a successful HTTP response can still represent an incomplete task.
| Evidence | Service response |
|---|---|
429 rate limit with retry-after |
Honor the wait. Use bounded backoff with jitter inside one retry budget. Return a degraded result or defer the job when the deadline cannot fit another attempt. |
429 without retry-after (spend cap reached) |
Do not retry: it keeps failing until access resumes. Degrade or defer the job and alert the owner. |
529 overloaded |
Back off with jitter inside the same budget. If overload persists, stop sending traffic and use a backup that meets the job's requirements. |
max_tokens |
Treat the output as incomplete. Increase the output allowance or continue if the task and remaining context allow it. |
model_context_window_exceeded |
Treat the response as truncated. Reduce the input or rebuild the turn with a compacted history before trying again. |
refusal |
Apply your safety policy. Route to an approved fallback only when the refusal category, documented model support and policy permit it. Otherwise decline or escalate. |
Measure availability on the availability path. A circuit breaker can stop sending traffic during persistent provider overload and admit a small number of probes after a cooldown. Track stops and refusals separately. A backup in another region, on another model or on another platform must pass the same requirements for the job, including features, data location and output contract.
For example, a 429 with a four-second wait can go to the deferred translation queue for an archive request. A live dispatcher with 900 ms left gets the labeled source-only view. In both cases the UI distinguishes the degraded result from a verified translation.