Home › Study guides › CCAR-P › Domain 3 › Lesson 3.8
CCAR-P · Domain 3 · 21% of the exam · Lesson 3.8 · 19 min read Updated for the December 7, 2026 exam guide (v1.1)
Production reliability controls: rate limits, retries, idempotency and fallback
Read the failure pattern in error traces or throughput data and specify the reliability control that fixes it without creating duplicate side effects.
Written against skill 3.8 of the official CCAR-P exam guide (Version 1.1, effective December 7, 2026). An independent resource, not affiliated with Anthropic; the practice questions are written from scratch.
3.8.1 Why a working integration fails on its busiest morning
Corrowan Home sells furniture online, and every order ends with a two-person crew from its carrier, Dovetail Freight, carrying a sofa up someone's stairs. Customers reschedule deliveries through a chat assistant built on Claude Sonnet 5.5. The agent has four tools: get_order and find_delivery_slots only read, while book_delivery_slot reserves a crew (Dovetail charges a booking fee) and send_order_sms texts the customer. For three months it worked without a page.
Then came the winter sale. At 09:00 on Saturday, conversations jumped from about 40 a minute to 400. Nkem Adeyemi, Corrowan's solution architect, pulled the traces on Monday. They show a burst of 429 errors in the first six minutes, a twenty-minute run of 529 errors before noon, and booking calls to Dovetail timing out after ten seconds. Worst of all, 61 customers had two or three crews booked for the same afternoon, each with a matching pile of texts.
Nothing in the model changed, and no prompt would have prevented any of it. A model call that works once does not tell you what happens under surge, partial failure and timeouts. That is the job of reliability controls: rate-limit handling, retry and backoff, idempotency for side-effecting tools, and fallback routing. Each one fixes a different failure pattern, and the wrong one can make things worse.
3.8.2 Read the failure pattern before you pick a control
"We're getting errors, so add retries" sounds reasonable, and it is how Corrowan got duplicate crews. Retrying is a control for one family of failure. Applied to the others it does nothing, or it multiplies the damage. So the first step is classification: WHERE does the problem lie?
Every error in a Claude integration falls into one of four families. Your own quota is exhausted. The provider is short of capacity. Your request is wrong. Or, the dangerous one, the outcome is unknown: a call timed out and you cannot tell whether the action behind it happened.
Four failure families, four different controls
Your quota
rate_limit_errorRPM, ITPM, OTPM or ramp limitProvider capacity
overloaded_error, 5xxbusy or failing upstreamYour request
Unknown outcome
The Claude API tells you more than the status code, and an architect reads all of it. The error body carries a type, and some errors add error.details.error_code, which separates causes that share a status. Two headers matter for retries: retry-after says how many seconds to wait, and x-should-retry says whether retrying can help at all.
| Signal in the trace | What it means | Control it calls for |
|---|---|---|
429 rate_limit_error with retry-after |
A per-minute limit for that model is spent | Wait the stated seconds; pace future traffic |
429 with error_code ramp_limit_exceeded |
Usage grew too fast, even under your limits | Ramp up gradually; spread bursts |
429 with error_code enforced_spend_limit_reached, no retry-after |
The monthly spend cap is reached | Stop retrying; alert; raise the tier |
529 overloaded_error |
The API is busy across all users | Back off; reroute if it persists |
500 api_error |
An internal error | Retry unless x-should-retry is false |
| 400, 401, 403, 413 | Your request or credential is wrong | Do not retry; fix it |
| Client timeout on a side-effecting tool | The action may or may not have happened | Idempotency key before any retry |
Memorise the four families and the two headers. The set of error codes can grow, so code that meets one it does not know falls back to the type or status.
3.8.3 Rate limits: shape the traffic instead of absorbing the 429s
Nkem's first finding is the 09:00 burst. Corrowan's usage was far below its input tokens per minute limit, yet requests failed. To see why, you need to know how limits work. The API limits each model class in requests per minute (RPM), input tokens per minute (ITPM) and output tokens per minute (OTPM), using a token bucket: capacity refills continuously rather than resetting at the top of each minute. A per-minute limit may also be enforced over shorter intervals, so 60 requests a minute can behave like one a second, and a burst can fail while the minute's total looks fine.
There is a second limit that catches launch days. A ramp limit caps how fast your token usage on a model can grow. It sits a step above your recent peak and rises as successful traffic grows. Jumping tenfold in a minute trips it, with error_code ramp_limit_exceeded, even below your published limits. That was Saturday at 09:00.
The control for your own quota is traffic shaping: decide how fast requests leave your system instead of firing them and retrying the failures. A retry loop that absorbs 429s spends the same scarce capacity a second and third time.
Admission control in front of the model
anthropic-ratelimit-* headersremaining fallsSeveral levers widen the pipe before you need a bigger tier. Tokens read from the prompt cache do not count toward ITPM or ramp limits, so caching the long system prompt and tool definitions raises effective throughput. Non-urgent work belongs in the Message Batches API, which has its own limits and no ramp limit. Corrowan's nightly job summarising delivery feedback shared the limit with the chat agent, so Nkem gives it its own workspace with a lower ITPM limit: a runaway job can no longer starve customers. Finally, before a planned surge, warm traffic up in steps rather than switching it on at full volume.
3.8.4 Retry and backoff: one layer, a budget, and only errors that can heal
The second finding is uglier. During the 529 window, one customer message produced nine or more model requests. The SDK retries a failed request up to two times by default, three attempts in all. Corrowan's own wrapper also tried three times, and each of its attempts went through the SDK. Three times three is nine, aimed at a service that had just said it was overloaded. Stacked retry layers multiply, and they multiply at the worst possible moment. This is a retry storm, and the team built it with good intentions.
Retry with exponential backoff is the right control for transient failures, provided three things hold. ONE layer owns retries. That layer retries only what can heal: connection errors, timeouts, 408, 409, 429 and 5xx, following x-should-retry when it is present. And it has a retry budget: a cap on attempts and total time, after which the request fails fast and something else takes over.
The SDK already does most of this. It waits as long as retry-after says, otherwise it backs off exponentially, and max_retries sets the count. Look at three lines below: the single client-level retry setting, the spend-cap branch that refuses to retry, and the 400 branch.
import anthropic
# ONE retry owner: the SDK honours retry-after and x-should-retry
client = anthropic.Anthropic(max_retries=3, timeout=60.0)
def call_model(request):
try:
return client.messages.create(**request)
except anthropic.EnforcedSpendLimitReachedError:
alert_on_call("monthly spend cap reached") # retrying cannot help
raise
except anthropic.RateLimitError:
requeue_with_delay(request) # SDK retries spent: slow intake, do not loop
except anthropic.BadRequestError:
raise # a 400 fails the same way every time
The order of the except branches matters: the spend-cap error is a 429 too, so the narrow branch comes first, as the docs advise. Two more details. Many clients retrying on the same schedule hit the API in waves, so standard practice adds random jitter to each wait. And an error that arrives inside a stream, after the API has already returned 200, is not retried by the SDK; your code catches it and decides.
3.8.5 Idempotency: make a retried side effect land once
Now the duplicate crews. Dovetail's booking API was slow under its own sale traffic and took about twelve seconds to answer. Corrowan's tool code gave up at ten, reported a timeout, and retried. But the first request had not failed. Dovetail had booked the crew and was still writing its reply when the client hung up. Each retry booked another crew.
This is the failure every retry design must answer. A timeout on a side-effecting tool is not a failure; it is an unknown outcome. Retrying a read is harmless: find_delivery_slots twice returns the same slots twice. Retrying a write replays an action that may already be done. A model call is in between: retrying it costs tokens but changes nothing in the world, because Claude only proposes calls to your tools and your code executes them.
The control is an idempotency key: an identifier sent with the request so the receiving service can recognise a repeat and return the original result instead of acting again. A longer timeout only makes the race rarer; the key removes it.
The same timeout, with and without an idempotency key
Without a key
With a key
ord-88412:reschedule:v3 stored with booking refThe hard part is choosing the key, and the exam likes this detail. The key must identify the business intent, so it stays the same across every retry of that intent. Duplicates at Corrowan came from three places: the tool wrapper retrying, the model calling book_delivery_slot again after reading "timeout" in the tool result, and a crashed conversation replaying from its last checkpoint. A fresh random value per attempt stops none of them. The id of a tool_use block stops only the first, because a model's second call gets a new id. Nkem's key is the order number, the action and the reschedule version, so all three paths collapse into one booking.
Where the downstream API does not accept keys, the tool layer keeps its own record of key and result. After an unknown outcome it reads before it writes: it asks Dovetail for bookings on that order before sending another. Then it tells the model plainly what happened ("booked, reference DV-30917") so the agent has nothing to retry. The guard lives in code. A system prompt line saying "never book twice" is advice to a model that never saw the lost reply.
3.8.6 Fallback routing: another path when the provider side is down
The last pattern is the 529 run. For twenty minutes, about a third of model calls returned overloaded_error. Backoff helped individual requests, but customers waited a minute or more for a reply. When the provider side is short of capacity for longer than a retry budget can cover, the control is fallback routing: sending the request down another path that meets the same requirements.
Claude Code and the Agent SDK show the rule Anthropic applies in its own harness. You set fallbackModel (in Python, fallback_model) to one or more backup models. When the primary is overloaded, unavailable or returns another non-retryable server error, the session switches; the primary is tried again at the start of the next turn. Authentication, billing, rate-limit and request-size errors never trigger a switch. A fallback is for a sick provider path, not for your own quota or a broken request.
| Option | When it wins | What it costs |
|---|---|---|
| Fallback model tier | Sustained 529s or 5xx on one model; the backup passes the task's evals | Quality may drop; each model has its own prompt cache, so the first calls run uncached |
| Second surface or region | A provider or regional outage; residency and compliance allow both paths | Feature parity to check, two sets of credentials, quotas and runbooks |
| Degrade gracefully | No backup meets quality or policy; the work can wait | Latency: queue the request, call back, or hand to a person |
| Message Batches | Bulk, deferrable work, not a live conversation | Results arrive asynchronously; no use for synchronous side effects |
Nkem chooses the first and third rows. Claude Haiku 5.5 passes Corrowan's eval set for rescheduling, so the gateway routes there after a short run of 529s. The pattern is often called a circuit breaker: trip after N failures in a window, route around the primary, probe it again after a cool-down. If the backup also struggles, the agent tells the customer it will text a confirmed slot within the hour and queues the request.
Fallback has its own duplicate trap. Switching models for a model call is safe, since no tool has run. But if the fallback replays the whole turn from the top, book_delivery_slot runs again. Fallback is safe at Corrowan only because the booking key is already in place.
Which errors should trigger the fallback route
3.8.7 The exam traps
- ✗ Retrying every failed request the same way. ✓ Classify first: retry connection errors, timeouts, 429 and 5xx (respecting
x-should-retry); never retry 400, 401, 403, 413 or a spend-cap 429, because they fail identically every time. - ✗ Adding a retry wrapper on top of the SDK's own retries. ✓ Give retries one owner with a budget; stacked layers multiply attempts into a retry storm exactly when the API is overloaded.
- ✗ Lengthening timeouts or cutting the retry count to stop duplicate side effects. ✓ Attach an idempotency key; tuning makes the race rarer, while the key removes the mechanism.
- ✗ Generating a new idempotency key per attempt, or using the tool call's id. ✓ Derive the key from the business intent so the wrapper, the model and a replayed run all produce the same key.
- ✗ Telling the model in the prompt not to repeat an action. ✓ Enforce deduplication in the tool layer; the model may never see the lost result, and retries often happen in code it does not control.
- ✗ Falling back to another model on 429s or 400s. ✓ Reroute only for sustained overload or unavailability; shape traffic for quota errors and fix the request for 4xx.
3.8.8 Put it together: diagnose a trace and specify the control
You can now sort an error into its family. You can shape traffic for quota errors, give retries one owner and a budget, make side-effecting tools idempotent with an intent-derived key, and route around a sick provider path without repeating an action. Nkem's post-incident record lists exactly four controls, one per pattern, each with the trace that justified it.
The rest of Domain 3 connects here. These controls only work if someone sees the patterns, and instrumentation and monitoring gaps (3.4) is about the signals that surface a retry storm or a duplicate effect before a customer does. When an action is too costly to trust to any automated control, human approval gates (5.4) decide where a person must confirm it.
Key takeaways
- ✓ Classify every error before choosing a control: your quota, provider capacity, your request, or an unknown outcome.
- ✓ The status,
error.type,error_code,retry-afterandx-should-retrytogether tell you whether and when a retry can help. - ✓ Rate limits are per model in RPM, ITPM and OTPM with continuous refill and ramp limits; shape traffic, cache repeated input, move bulk work to Batches and isolate it with workspace limits.
- ✓ Retry only transient failures, with exponential backoff, jitter and a budget, and let exactly one layer own retries.
- ✓ A timeout on a side-effecting tool is an unknown outcome; an idempotency key derived from the business intent makes every retry path land once.
- ✓ Fallback routing to an evaluated model, surface or degraded mode is for sustained overload or unavailability, never for quota, billing or request errors, and it relies on idempotent tools.
Check your understanding
4 questions written for this lesson. Every answer option is explained, including the ones you did not pick. Nothing is stored.
CCAR-P practice questions are being rewritten
The 189 CCAR-P practice questions here were written for the previous exam guide and are tagged to its domains. New questions for the December 7, 2026 guide (v1.1) are being written. Until they are ready, the practice for the new guide is the questions at the end of every lesson, with every answer option explained. The old bank stays open for general practice.