CertPrep
Domain 2 · Lesson 2.1 · 8 min read

Reliability Engineering for Claude Services

Exam skillReliability Engineering for Claude Services

Evaluating and applying resilience patterns for production Claude integrations, including retry and backoff design, circuit breakers, graceful degradation, and cross-model, cross-region, and cross-platform fallbacks that distinguish rate limits from safety refusals from context-window stops while respecting per-platform feature parity.

Classify each failure a Claude integration sees (rate limit, overload, invalid request, length stop, context-window stop, refusal) and give it its own response, then add circuit breakers, retry budgets, graceful degradation and tested fallbacks across models, regions and platforms.

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

OutcomeWhat it meansCorrect response
429 rate_limit_errorYour requests exceed a limitWait at least retry-after, back off with jitter, retry on the same model
529 overloaded_error, brief 500sTransient capacity or server problemA few retries with backoff; then a tested fallback
Overload lasting many minutesSustained capacity problemCircuit breaker plus fallback routing
400 invalid_request_error, 413 too largeThe request itself is wrongNever retry as is; fix or shrink it, alert
401, 403Credentials or permissionsFix credentials; retries will not help
stop_reason: max_tokensOutput hit its budgetRaise the budget, ask for less, or continue from the partial response
stop_reason: model_context_window_exceededInput outgrew the windowCompact or clear, then resend
stop_reason: refusalThe model declinedSafety path: safe message, log, review; never route around it

Retries that help

  • Honor retry-after and 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

FallbackMust be true before relying on it
Cross-modelThe fallback model passes the task's quality floor on the evaluation set
Cross-regionThe 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

Question 1

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.

Question 2

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.

Question 3

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

Exercise · about 25 minCase: Cobalt Health Network

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.

  1. Write the classification table for the service's outcomes and the response to each.
  2. Design the retry controls, including where retries happen and how load is bounded.
  3. Define degradation for a long outage, given that a clinician must have a summary within 24 hours.
  4. Specify the refusal path.
    Done when: a refused transcript cannot be retried on another model.
Check your work
Show model answer

1. Classification

OutcomeResponse
429Wait retry-after plus jitter; same model
529 or brief 500Up to 3 retries with exponential backoff
Overload over 5 minutesBreaker opens; work is queued
400 or 413No retry; alert the on-call engineer with the request ID
max_tokensRe-run once with a 10,000-token budget, or generate the summary section by section
refusalRefusal 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.

Key termsAmazon BedrockCircuit breakerExponential backoffRate limitVertex AI

Sources