Home › Study guides › CCDV-P › Domain 2 › Lesson 2.1
CCDV-P · Domain 2 · 20% of the exam · Lesson 2.1 · 21 min read New in the December 7, 2026 guide release (v1.0)
Reliability engineering: classify, retry, break and fall back
Classify each Claude failure before handling it: backoff for 429 and 529, circuit breakers, graceful degradation, and fallbacks that pass a parity check.
Written against skill 2.1 of the official CCDV-P exam guide (Version 1.0, effective November 2026). An independent resource, not affiliated with Anthropic; the practice questions are written from scratch.
2.1.1 Why one retry path fails three different ways
Ring a busy colleague and get no answer, and you try again in a few minutes. Ask them for something they have decided not to do, and ringing back every ten seconds changes nothing except their mood. Ask for a ten-page report on a postcard, and no number of calls makes it fit. People sort these cases without thinking. A retry loop does not, unless you teach it.
Meridian Pay issues cards to 3 million cardholders. Its payment-dispute assistant handles about 9,000 dispute conversations a day: it gathers the transaction and the cardholder's account of what went wrong, drafts the case for the chargeback team, and explains what happens next. Each conversation makes about six model calls, so the service runs some 54,000 calls a day, peaking near 150 a minute on Monday mornings.
Its reliability design was one rule. Any failed call is retried three times, one second apart. If it still fails, the same request goes to a smaller Claude model, and if that fails too, to Amazon Bedrock. The rule looked thorough in review. In its first bad week it multiplied the load during a rate-limit episode, re-sent truncated summaries four times, paid for refusals it could never overturn, and failed on Bedrock at the one moment it was needed.
The fix is not more retries, or fewer. It is failure classification: read what kind of failure each call returned, then give each class the one response that can work. Every resilience pattern in this lesson, from backoff to circuit breakers to a cross-platform fallback, is only as good as the classification in front of it.
One retry path versus a classifier
One path for everything
more cost, same failures
Classify first
stop_reasoneach class gets the fix that can work
2.1.2 Classify before you handle: errors and stop reasons
Here is the distinction the exam returns to again and again: a Claude call can go wrong in two different places. An error is an HTTP 4xx or 5xx response. The API did not produce an answer, and the body names an error type. A stop reason arrives on a successful HTTP 200 response: generation ended, and stop_reason says why. Three stop reasons mean the answer is not what you wanted: max_tokens, refusal and model_context_window_exceeded.
The two families need different code and different monitoring. A dashboard built on error rates never sees a refusal or a truncated answer, because both are 200s. Streaming adds a third case. Once a stream has started, the API has already returned 200, so a failure such as overloaded_error arrives as an error event inside the stream, and the SDK does not retry it. Your handler must check the error's type, not only its status.
Meridian's first step was a table that every handler in the service now shares.
| Signal | What it means | What your code does |
|---|---|---|
429 rate_limit_error |
A rate limit or a ramp limit (ramp_limit_exceeded) was hit |
Wait for retry-after, retry with backoff, slow the sender |
429 with enforced_spend_limit_reached |
The monthly spend cap was reached; no retry-after |
Stop retrying, page the owner, degrade |
529 overloaded_error |
The API is temporarily overloaded for all users | Back off with jitter; if it persists, open the breaker or fall back |
500 api_error, 504 timeout_error |
An internal error or a timeout | Retry unless x-should-retry is false; stream long requests |
| 400, 401, 403, 413 | The request, credential, permission or size is wrong | Never retry unchanged; fix the request and alert |
stop_reason: "max_tokens" |
The answer hit your max_tokens |
Raise the budget or continue the response |
stop_reason: "model_context_window_exceeded" |
The answer filled the model's context window | Treat it as truncated; shrink the input |
stop_reason: "refusal" |
A safety classifier declined; stop_details.category says why |
Send it to the refusal path, never the retry loop |
Memorise the split: 429, 529, 5xx and timeouts are the only signals that time can fix. Recognise the rest by what has to change before a second attempt can succeed. Note the two kinds of 429: one is a rate limit that clears in seconds, the other a spend cap that keeps failing until access resumes, and only error.details.error_code tells them apart. Every response also carries a request-id header; log it, because support needs it for any failure you escalate.
2.1.3 Retries that help: backoff, jitter, retry-after and a budget
Once you know a failure is retryable, the next question is how. Meridian's loop retried immediately and at fixed one-second intervals, and it sat on top of the SDK's own retries. The Anthropic SDKs already retry a failed request up to two times by default (max_retries changes it). They retry connection errors, timeouts, 408, 409, 429 and every status of 500 and above, follow the x-should-retry header when it is present, and wait for retry-after when the response has one. Otherwise they back off exponentially from 0.5 to 8 seconds.
Stack Meridian's four attempts (one call plus three retries) on the SDK's three attempts each, then repeat that on two more targets, and one failing call can become 36. That is retry amplification: during a rate-limit episode, the retries become most of the traffic that keeps the limit tripped. Pick one layer to own retries. Either let the SDK do it and keep your own loop for routing decisions, or set max_retries=0 and own the whole policy.
Three rules make that layer safe. Exponential backoff doubles the wait after each failure, giving the dependency room to recover. Jitter randomises each wait, so thousands of clients that failed together do not retry together. Think of a stadium emptying through one gate: staggered departures flow, a single whistle jams it. Honour retry-after over your own guess; for a ramp limit, the docs advise holding traffic where requests succeed and growing it by at most one step a minute. Finally, a retry budget caps retries as a share of first attempts, for example 10% per minute across the service. It comes with a per-request deadline: a cardholder in chat should not wait 40 seconds for an error.
Here is Meridian's classifier for errors. Look at the spend-cap check, which must come before the general 429 rule, and at the use of err.type, which also catches error events inside a stream.
import anthropic
RETRYABLE = {"rate_limit_error", "overloaded_error", "api_error", "timeout_error"}
def classify_error(err: anthropic.APIError) -> str:
if isinstance(err, anthropic.APIConnectionError):
return "BACKOFF_RETRY" # network failure or client timeout
if err.error_code == "enforced_spend_limit_reached":
return "STOP_AND_PAGE" # spend cap: no retry-after, keeps failing
if err.type in RETRYABLE:
return "BACKOFF_RETRY" # time can fix it; works for stream error events
return "FIX_REQUEST" # 400, 401, 403, 413: same request fails again
2.1.4 Length stops and refusals are answers, not outages
The question that trips people up is what to do with a 200 that is not a usable answer. Meridian's case summaries were capped at max_tokens: 800. Disputes covering 30 transactions stopped at max_tokens, the loop counted that as a failure, and it sent the identical request again. The same budget produced the same cut. A length stop is not bad luck. It is your budget, and the fix is to raise max_tokens for that route or continue the response. If the cut-off answer ends in an incomplete tool call, retry it with a higher max_tokens. A higher max_tokens does not count against your output-tokens-per-minute limit, which counts only tokens actually generated.
model_context_window_exceeded looks similar but has a different cause: input plus output filled the model's whole context window. Treat the response as truncated and shrink the input, for example by sending the disputed transactions instead of a year of statements. If the input alone is too large, the API returns a 400 invalid_request_error ("prompt is too long"). That is a request to fix, not a retry.
A refusal is Claude's safety classifiers declining the request, returned as a normal 200 with stop_reason: "refusal" and a stop_details.category. The docs are blunt: re-sending a refused request to the same model usually earns another refusal. Meridian learned something sharper. Its dispute-classification prompt asked for a reasoning field in the JSON output, which triggers the reasoning_extraction category. That category is billed even before any output, and has no recommended fallback model. The loop paid five times per refusal for nothing. The fix was the prompt: ask for a short explanation of the evidence instead.
Three kinds of 200 that are not usable answers
max_tokens
max_tokens or continue the responsemodel_context_window_exceeded
refusal
stop_details.categoryreasoning_extraction: fix the promptFor other categories, the documented path is a retry on a different model. On the Claude API and on Claude Models on Google Cloud (Anthropic managed), server-side fallback (in beta) does it inside one call: set fallbacks to "default" with the server-side-fallback-2026-07-01 beta header. Everywhere else, and for Claude Haiku 5.5, which has no server-side fallback, the SDK's refusal-fallback middleware retries on a list of models you choose. When every option declines, Meridian hands the cardholder to a dispute specialist. Discard any partial output from a mid-stream refusal, and count refusals as their own metric, since error dashboards never see them.
2.1.5 Circuit breakers and graceful degradation
Backoff handles a blip. It does not handle twenty minutes of 529s. During one capacity event, every Meridian cardholder waited through the full retry sequence before getting an error. The missing piece is a circuit breaker: a small state machine in front of each dependency that stops calling it while it is clearly failing.
It works like the breaker in your fuse box. In the closed state, calls flow and your code counts failures over a sliding window. When failures cross a threshold, say half of at least 20 calls in 30 seconds, the breaker opens: calls fail at once, without touching the dependency, for a cool-off period. Then it goes half-open and lets a few probe calls through. If they succeed, it closes; if not, it opens again. Fast failure is the point. It frees resources and gives your code an immediate, explicit signal to fall back or degrade.
A circuit breaker's three states
Two design choices matter more than the numbers. First, count only capacity failures: 429, 529, 5xx and timeouts. A 400 from one cardholder's broken upload or a refusal says nothing about the dependency's health, and counting them lets a single bad client trip the breaker for everyone. Second, keep one breaker per target, meaning model, platform and region, so the fallback has its own state.
Graceful degradation is what you serve when every breaker is open. Meridian asked what the assistant must never fail to do. The answer was to record the dispute before the card network's deadline. Its degraded mode is a guided form: transaction, amount and a reason chosen from a fixed list. It returns a case reference and an honest message that a specialist will review the case. It skips optional generation, such as explaining chargeback rules, and it never states an outcome. Degraded mode is a product state you design and test, not an error page.
2.1.6 Fallbacks across models, regions and platforms
A fallback is worth having only for the failures it can fix. Another model, region or platform adds capacity, so it helps with sustained 429s, 529s and outages, and through the refusal path, with declines. It cannot fix a 400, a length stop or an oversized input, because those travel with the request. Meridian's chain sent every failure everywhere, so most fallback traffic was doomed before it left.
Each kind of target also has its own catch. A different model may have a different context window: many current models have 1M tokens, while others have 200k, so a long dispute history that fits the primary returns "prompt is too long" on the fallback. A different region on the Claude API adds no headroom, because rate limits are shared across all inference_geo values. A different platform can add capacity, because its limits are set elsewhere: AWS sets Bedrock quotas, and Foundry limits are managed through Azure. Google Cloud has two offerings. Claude Models on Google Cloud (Anthropic managed) runs as its own Anthropic organization, reached with the SDK's AnthropicGoogleCloud client; the Google-managed offering has limits managed by Google Cloud and uses AnthropicVertex.
Platforms add the feature parity check: the fallback must accept the same request. Meridian's Bedrock leg sent cardholder evidence as a Files API file_id and set the fallbacks parameter. Bedrock supports neither, so every fallback call returned 400 during the outage it existed for. Each feature's documentation page has an availability section naming the platforms that support it. Meridian now keeps a capability profile per target and checks every fallback request against it before sending.
| Fallback target | What it fixes | What to check first |
|---|---|---|
| Smaller or older model, same platform | Overload or rate limits on one model | Context window, output quality on your evals |
| Another region | Regional outages, where a platform offers regions | Data residency; Claude API rate limits are shared across inference_geo |
| Amazon Bedrock | A capacity incident with its own AWS quota | No Files API, server-side fallback or Message Batches; anthropic. model ids; global or regional endpoint |
| Microsoft Foundry | A capacity incident with its own Azure limits | No Message Batches or server-side fallback; Azure-hosted deployments lack the Files API; no anthropic-ratelimit-* headers |
Learn the decision, not the cell values; platform support changes, so check the availability pages when you build. Residency belongs in the same check. On Bedrock, a global endpoint routes across regions for availability, while a regional endpoint keeps traffic in one geography for a 10% premium. A payments firm with a US data commitment needs the regional route. Last, send a small share of live traffic down every fallback path all the time. A path first used during an incident will fail in an incident.
2.1.7 The exam traps
Every trap here treats different failures as one, or trusts a fallback nobody has checked.
- ✗ Retrying every failure through one path, and adding attempts when the error rate rises. ✓ Classify first. Retries help only rate limits, overloads, server errors and timeouts; more attempts multiply cost and load for everything else.
- ✗ Retrying immediately or at fixed intervals, in several layers at once. ✓ One retry layer with exponential backoff, jitter,
retry-aftertaking precedence, a retry budget and a per-request deadline. - ✗ Treating a refusal as a transient error and resending it to the same model. ✓ A refusal path that reads
stop_details.category: fix the prompt forreasoning_extraction, use a documented fallback model for other categories, hand off when it stands. - ✗ Sending a
max_tokensor context-window stop to the fallback model. ✓ Raise the budget or continue the response for length stops, and shrink the input when the context window is full. - ✗ Counting 400s and refusals toward the circuit breaker. ✓ Count only capacity failures, with one breaker per target, so one bad client cannot cut off everyone.
- ✗ Assuming a fallback platform accepts the same request. ✓ A per-target capability profile checked before sending, and live traffic on every fallback path.
2.1.8 Put it together: rebuild a fallback chain that classifies
You now have every piece: a classification table, one disciplined retry layer, a refusal path, circuit breakers, a degraded mode and fallbacks gated by parity. The quickest way to own them is to build a small version and then break the classifier on purpose.
The rest of the domain builds on this layer. Throughput management (2.2) decides how much traffic each target receives and how queues absorb bursts, so fewer calls need a retry at all. Production MCP and change management (2.3) keeps configuration in parity across platforms as models and prompts change. Incident response (4.2) takes over when the breakers open and stay open.
Key takeaways
- ✓ Classify every failure before handling it: errors arrive as HTTP 4xx or 5xx, while
max_tokens,refusalandmodel_context_window_exceededarrive as stop reasons on HTTP 200. - ✓ Only rate limits, overloads, server errors and timeouts are retryable, and a spend-cap 429 is not, which
enforced_spend_limit_reachedreveals. - ✓ Retry in one layer with exponential backoff, jitter,
retry-afterfirst, a retry budget and a deadline, so retries never amplify an overload. - ✓ Raise the budget for length stops, shrink the input for context-window stops, and send refusals to a path that reads
stop_details.category. - ✓ A circuit breaker per target counts only capacity failures and fails fast, and graceful degradation keeps the critical path working with honest messages.
- ✓ Fall back to another model, region or platform only for capacity failures and declines, after a parity check of features, context window and residency, on a path exercised with live traffic.
Check your understanding
4 questions written for this lesson. Every answer option is explained, including the ones you did not pick. Nothing is stored.
CCDV-P practice questions are being written
There is no CCDV-P question bank on this site yet. The practice questions are being written now. Until they are ready, work through the free study guide: every lesson ends with questions that check your understanding, and every answer option is explained.
Back to Domain 2 → The CCDV-P exam guide →
The CCDV-P course will hold the same study guide as a book, for reading in the app.