What you need to know
The most common reliability bug in Claude integrations is a single retry path for every failure. Different outcomes need different responses, and treating them alike multiplies cost, repeats refusals and turns outages into retry storms. Classify first, then respond.
The classification table
| Outcome | What it means | Correct response |
|---|---|---|
429 rate_limit_error | Your requests exceed a limit | Wait at least retry-after, back off with jitter, retry on the same model |
529 overloaded_error, brief 500s | Transient capacity or server problem | A few retries with backoff; then a tested fallback |
| Overload lasting many minutes | Sustained capacity problem | Circuit breaker plus fallback routing |
400 invalid_request_error, 413 too large | The request itself is wrong | Never retry as is; fix or shrink it, alert |
| 401, 403 | Credentials or permissions | Fix credentials; retries will not help |
stop_reason: max_tokens | Output hit its budget | Raise the budget, ask for less, or continue from the partial response |
stop_reason: model_context_window_exceeded | Input outgrew the window | Compact or clear, then resend |
stop_reason: refusal | The model declined | Safety path: safe message, log, review; never route around it |
Retries that help
- Honor
retry-afterand add jitter so many clients do not retry in step. - Retry at one layer only. Retries in the client, the agent loop and the gateway multiply into each other.
- Use a retry budget: cap retries as a share of total requests across the service, so a partial outage cannot multiply load.
- Never retry a side effect without an idempotency key (see lesson 1.2).
Circuit breakers
When a dependency is failing, immediate retries from every instance create a storm that delays recovery and can trigger rate limits after capacity returns. A circuit breaker opens after repeated failures (calls fail fast), probes with a few requests after a cooldown, and closes when they succeed. Use one per dependency: the Claude API, and each tool backend. At the tool boundary, an open breaker returns an error result immediately ("shipping system unavailable, retry later"), so the agent can tell the user and continue with what still works instead of waiting 30 seconds per call.
Graceful degradation
Keep the core function available with reduced capability:
- show the decision with standard reason codes when an explanation cannot be generated;
- queue non-urgent work and finish it when the service recovers;
- decouple a page with a strict availability target from a slower analysis step with a durable queue, an "analysis pending" state and a dead-letter queue.
Error pages, invented answers and users waiting on ten-minute retries are not graceful.
Fallbacks: model, region, platform
| Fallback | Must be true before relying on it |
|---|---|
| Cross-model | The fallback model passes the task's quality floor on the evaluation set |
| Cross-region | The region supports the same model and the features your requests use |
| Cross-platform (first-party API, Bedrock, Vertex AI, Foundry) | A separate request configuration that uses only features that platform supports |
Every fallback response should be logged with its model and path, with an alert when the fallback share passes a threshold. An untested fallback turns an availability incident into a quality incident. Refusals are never part of the availability chain: retrying a refused request on another model can route around a legitimate safety decision.
Streaming and long requests
Long non-streaming requests can exceed client or network idle timeouts. Stream long generations. With streaming, an error can arrive mid-stream after some text was shown: detect it, mark the partial output as incomplete, retry, and replace the partial output rather than appending to it.
Truthful outcomes
Reliability includes reporting what really happened. If Claude's call succeeded but the tool's side effect failed, the agent must report the failure, not success.
In the exam
Reliability items show a mix of failures in traces and a proposed policy. Classify each outcome, then pick the option that gives each class its correct response, bounds retry load, and uses only tested fallbacks. Distractors increase retries for everything, switch traffic permanently, remove the fallback, retry 400s, rotate keys to dodge limits, or treat refusals as transient.
Check your understanding
Traces show 429s, max_tokens stops and refusals in one retry path. Which response is right for the length stops?
Show answer
Answer: A. A length stop repeats exactly when the same request is resent. The budget, not the model or the wait, is the cause.
A regional overload lasted 20 minutes, and when it ended a retry wave triggered rate limits for 15 more. Which control prevents the second outage?
Show answer
Answer: D. The breaker stops the storm and lets traffic return gradually. Faster retries or more clients send the same wave.
Which outcome should never be retried as is?
Show answer
Answer: B. An invalid request fails the same way every time. The other three are transient and suit bounded retries with backoff.
Apply it: Write Cobalt's failure-handling policy
Cobalt's visit-summary service calls Claude once per visit transcript, with outputs up to 6,000 tokens. Last quarter, during a provider capacity incident, it retried every failure immediately and was rate-limited for 40 minutes after recovery. Logs also show some summaries truncated mid-section and a handful of refusals on transcripts that discuss self-harm, which the service retried five times each.
- Write the classification table for the service's outcomes and the response to each.
- Design the retry controls, including where retries happen and how load is bounded.
- Define degradation for a long outage, given that a clinician must have a summary within 24 hours.
- Specify the refusal path.
Done when: a refused transcript cannot be retried on another model.
Show model answer
1. Classification
| Outcome | Response |
|---|---|
| 429 | Wait retry-after plus jitter; same model |
| 529 or brief 500 | Up to 3 retries with exponential backoff |
| Overload over 5 minutes | Breaker opens; work is queued |
| 400 or 413 | No retry; alert the on-call engineer with the request ID |
max_tokens | Re-run once with a 10,000-token budget, or generate the summary section by section |
refusal | Refusal path (step 4) |
2. Retry controls. Retries happen only in the summary worker, not in the HTTP client or gateway. A service-wide retry budget caps retries at 10% of requests per minute. A circuit breaker on the Claude API opens after 20 consecutive failures, probes with 5 requests every 60 seconds, and closes when 4 succeed.
3. Degradation. Transcripts go onto a durable queue; the clinician portal shows "summary pending" with the transcript available. Workers drain the queue after recovery at a rate within limits. Anything still unsummarized after 20 hours alerts the clinical operations lead, who assigns manual summaries.
4. Refusals. A refusal is logged with the visit ID (no content), the visit is flagged for the clinician to summarize, and a weekly review checks refusals for over-blocking. The refusal path is separate from the retry and fallback logic, so no other model is called.