Applications and Integration
Integration Resilience
Exam objective: Analyzing failing or degraded integration code and its error output to find the defect and select a correction consistent with documented API error semantics. Defects include mishandled streaming events and terminal-event semantics, retry and fallback logic that does not distinguish Anthropic's error classes (rate limits, overloaded, invalid request, timeout), and faulty multi-format ingestion through the Files API.
What the exam tests
You are given failing or degraded integration code with its error output. You must locate the defect and pick the correction that matches documented API semantics. Three areas recur: streaming consumers, retry and fallback logic across error classes, and file ingestion.
Key rules
Streaming
- Event flow:
message_start(empty content), then per blockcontent_block_start, deltas,content_block_stop; thenmessage_delta; thenmessage_stop. stop_reasonis null inmessage_startand arrives inmessage_delta, whoseusagecounts are cumulative.- An
errorevent (for exampleoverloaded_error) can arrive after HTTP 200. SDKs surface it as an exception and do not retry it. - Ignore pings and tolerate unknown event types.
- Tool input arrives as
input_json_deltastring fragments. Concatenate and parse at block stop:
if delta.type == "input_json_delta":
buf[event.index] += delta.partial_json # parse at content_block_stop
- Resuming an interrupted stream: Claude 4.5 and earlier accept the partial text as an assistant prefill; 4.6 and later need a user message with the partial text asking to continue. Only text is partially recoverable.
Terminal states (successful responses, not errors)
max_tokens: truncated; an incompletetool_usemeans retrying with a higher limit.model_context_window_exceeded: also treat as truncated.pause_turn: send the assistant content back unchanged with the same tools.refusal: discard partial output; retry on a fallback model (except thereasoning_extractioncategory, where you change the prompt instead).
Errors
| Status | Type | Handling |
|---|---|---|
| 400 | invalid_request_error | Fix the request (also your own spend limit) |
| 401 / 403 | authentication / permission | Fix credentials or access |
| 404 | not_found_error | Check path, IDs, workspace |
| 413 | request_too_large | Shrink the payload |
| 429 | rate_limit_error | Honor retry-after; check error.details.error_code |
| 500 / 504 | api_error / timeout_error | Retry with limits; stream long requests |
| 529 | overloaded_error | Back off and retry |
- SDKs retry twice by default (connection errors, timeouts, 408, 409, 429, 500+), following
x-should-retryandretry-after. - A ramp limit 429 (
ramp_limit_exceeded) means traffic grew too fast: wait, then increase gradually. - Server-side
fallbacksreacts only to classifier refusals, never to 429, 529 or 5xx.
Files API
- PDF and
text/plaingo indocumentblocks, images inimageblocks, datasets for code execution incontainer_upload. - Convert .docx and .xlsx to text (or PDF) for reading.
- Files are scoped to a workspace. Deleted, expired or inaccessible files make requests fail.
- Uploaded files cannot be downloaded; only files created by skills or code execution can.
- PDFs must not be encrypted; dense ones can overflow context before the page limit.
Traps
- Treating HTTP 200 or a closed connection as proof that a stream completed.
- Retrying every 429: the tier spend cap has no
retry-afterand keeps failing. - Retrying 400 or 413 unchanged.
- Expecting a larger
max_tokensto affect output rate limits; it does not count toward OTPM. - Parsing each
partial_jsonfragment on its own. - Relabeling a binary file as
text/plain. - Monitoring only error rates, which never shows refusals.
Decide quickly
| Situation | Choice | Why |
|---|---|---|
| Long generation times out without a response | Stream and accumulate, or use Batches | Idle connections get dropped |
429 with retry-after | Wait that long, then retry | Earlier attempts may fail |
429 with enforced_spend_limit_reached | Stop and alert | Access is paused |
| 529 persists after retries | Application-level failover or defer | Refusal fallback does not cover it |
pause_turn | Resend with assistant content appended | The server loop is unfinished |
| Unparseable streamed tool input | tool_result with is_error: true | Claude can correct the call |
| Large or reused PDF | Upload and reference file_id | Smaller requests |