Claude turn errors drop the CLI's API error text: other API errors read "gave up after repeated API errors", and every 429 reads "usage limit reached" #13399
Summary#
When a Claude turn ends on an API error, Claude Code first emits a synthetic assistant message that carries error (an SDKAssistantMessageError) and the real text, such as API Error: 400 <message>. It then sends a result with terminal_reason: "api_error". #10321 and #10549 use two of those error values (authentication_failed and rate_limit) to name the cause. Everything else becomes T3's own sentence, and the CLI's text is dropped from the turn error:
terminalResultErrorinapps/server/src/provider/Layers/ClaudeAdapter.tsmapsapi_errorwithout a latched hint toClaude gave up after repeated API errors.handleAssistantMessagesetslatestAssistantRateLimitedfor anyerror: "rate_limit". Every 429 then ends asClaude usage limit reached. Send the message again once the limit resets.That includes per-minute rate limits (rate_limit_error: This request would exceed your account's rate limit) and 429s from a gateway set throughANTHROPIC_BASE_URL, where no subscription window was rejected and norate_limit_eventarrived.
The chat still shows the CLI's line as an assistant message. The runtime.error activity, the failed turn, the thread's error state and notifications carry only the generic sentence, so a client or API consumer reading the turn error cannot tell a refused request from an overload or a gateway cooldown.
Two cases we hit:
| CLI assistant text | T3 turn error |
|---|---|
API Error: 400 Claude Code 2.1.258 does not support this model; version 2.1.280 or newer is required. ... | Claude gave up after repeated API errors. |
API Error: Request rejected (429) · rate_limit_error: This request would exceed your account's rate limit. ... | Claude usage limit reached. Send the message again once the limit resets. |
Steps to reproduce#
We saw both on real turns. The shortest trigger we know of:
- Point the Claude provider's
ANTHROPIC_BASE_URLat a stub that answersPOST /v1/messageswith HTTP 400 and{"type":"error","error":{"type":"invalid_request_error","message":"example refusal"}}. - Send a message in a Claude thread. The chat shows
API Error: 400 example refusal, and the turn fails withClaude gave up after repeated API errors. - Make the stub answer HTTP 429 with
{"type":"error","error":{"type":"rate_limit_error","message":"example rate limit"}}and noanthropic-ratelimit-unified-*headers. The turn fails withClaude usage limit reached. Send the message again once the limit resets.
Expected#
The turn error names the cause the CLI reported:
- Keep the text of the last assistant message in the turn that carries
error, and use it as the failure hint forapi_errorwhen no more specific hint applies. The sign-out copy stays as it is. - Use the usage-limit sentence only when a usage window is known to be rejected. Otherwise show the CLI's 429 text.
Versions#
T3 Code 0.0.43-nightly.20260924.2187 (78af372c). ClaudeAdapter.ts has not changed on main since 2026-09-16. Claude Code 2.1.280.
juliusmarminge added labelsbug
juliusmarminge added labelsvia-triage
Note
🤖 Claude Opus 5.5 responding on behalf of Theo
Thanks for the report. One part of this is fixed on main in #19136. Please test on the nightly built from main on 2026-10-21, or on the next stable release. One part is still open: assistant-only API errors and non-usage-window 429s still get generic or misleading turn errors. If that part still matters to you, please open a new issue for that part only.
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Confirmed on
main. Both rows in the table are what the adapter does today. The chat line and the turn error are filled from different fields.handleAssistantMessagekeeps only two values fromSDKAssistantMessage.error:authentication_failedbecomes the sign-out sentence, and anyrate_limitsetslatestAssistantRateLimited. The snapshot text is still emitted as an assistant message (backfillAssistantTextBlocksFromSnapshot), which is why the transcript showsAPI Error: ….handleResultMessagethen builds the turn error from a hint, not from that text:rate_limit_event, orlatestAssistantRateLimited, becomesClaude usage limit reached. Send the message again once the limit resets.terminal_reason: "api_error"becomesClaude gave up after repeated API errors.That same string is
runtime.errorandturn.completed.errorMessage, and ingestion copies it ontosession.lastError(chat banner and sidebar). Desktop and in-app notifications do not include it: a failed turn is titled "Thread failed" and the body is the thread title.resultOutcomenever readsSDKResultSuccess.result. In@anthropic-ai/claude-agent-sdk0.3.276 (Claude Code 2.1.276; this report is 2.1.280), a success result withis_error: truecarries the error text inresult. The adapter only looks atresult.errors, which success results do not have. The mapping itself is from #10321 and #10549 (2026-09-07). The file's last edit, on 2026-09-16, did not change it.The SDK already distinguishes the causes we collapse:
invalid_request,model_not_found,billing_error,account_on_hold,verification_required,oauth_org_not_allowed,server_error,overloaded,max_output_tokens,cloud_credential_error,unknown, andrate_limit.rate_limitis one code for a subscription window and for an ordinary 429, which is why a per-minute orANTHROPIC_BASE_URL429 with norate_limit_eventis reported as a usage limit.One constraint from #10549: a retry of a real usage limit often sends only
assistant.error: "rate_limit"and no newrate_limit_event. That flag is replaced by the next parent response and is ignored on subagent messages. Stopping at "usage-limit sentence only when a window was rejected" is right for the false 429, but the assistant-only retry must not fall back to "gave up after repeated API errors." The CLI text is the right fallback there, capped the way #12652 caps text-generation errors. Keep, ahead of that text: sign-out copy, a rejected usage window, HTTP 529, a listed non-diagnostic error, and every terminal reason other thanapi_error. Anapi_errorwith no assistant error and an emptyresultshould stay on the generic sentence; that is the case the current give-up test covers.