fix(claude): name the expired login or usage limit instead of a generic API error - #10321
Conversation
| // The CLI reports an expired login as a synthetic assistant message and | ||
| // then ends the turn as a plain API error, so latch the real cause here. | ||
| if (message.error === "authentication_failed") { | ||
| context.turnState.failureMessage = claudeSignedOutMessage(claudeSettings); |
There was a problem hiding this comment.
🟡 Medium Layers/ClaudeAdapter.ts:3255
The recovery command points at the wrong config directory or fails to execute for custom homePath values. claudeSignedOutMessage uses the raw path, so relative paths are resolved from the terminal's directory instead of the adapter's path.resolve(expandHomePath(homePath)), and whitespace or shell metacharacters are not quoted. Generate the command from the resolved config path and shell-quote it.
Also found in 1 other location(s)
apps/server/src/provider/Drivers/ClaudeHome.ts:62
claudeSignedOutMessageinserts the rawhomePathinto a shell command rather than the path used bymakeClaudeEnvironment, which ispath.resolve(expandHomePath(homePath)). Thus a valid relative configuration such ashomePath: ".claude-work"is resolved relative to the server process but the suggested command resolves it relative to whichever directory the user opens in their terminal; paths containing spaces also split the unquoted assignment. Following the displayed recovery instruction logs into a different config directory, leaving the adapter's actual instance signed out.
🤖 Copy this AI Prompt to have your agent fix this:
In file @apps/server/src/provider/Layers/ClaudeAdapter.ts around line 3255:
The recovery command points at the wrong config directory or fails to execute for custom `homePath` values. `claudeSignedOutMessage` uses the raw path, so relative paths are resolved from the terminal's directory instead of the adapter's `path.resolve(expandHomePath(homePath))`, and whitespace or shell metacharacters are not quoted. Generate the command from the resolved config path and shell-quote it.
Also found in 1 other location(s):
- apps/server/src/provider/Drivers/ClaudeHome.ts:62 -- `claudeSignedOutMessage` inserts the raw `homePath` into a shell command rather than the path used by `makeClaudeEnvironment`, which is `path.resolve(expandHomePath(homePath))`. Thus a valid relative configuration such as `homePath: ".claude-work"` is resolved relative to the server process but the suggested command resolves it relative to whichever directory the user opens in their terminal; paths containing spaces also split the unquoted assignment. Following the displayed recovery instruction logs into a different config directory, leaving the adapter's actual instance signed out.
There was a problem hiding this comment.
Fixed in 451a65f7. The hint now uses the effective environment passed to the SDK query, including inherited CLAUDE_CONFIG_DIR, and describes its literal value and the query working directory separately from the login command. It no longer generates an unquoted shell assignment. Focused adapter tests compare the actual query env/cwd with the final error for configured relative paths, inherited relative paths, spaces, apostrophes, dollar characters, and edge whitespace. All 120 touched-file tests, targeted lint, and server typecheck pass. Authentication guidance remains held for human review. GPT 6 Astra via Codex in T3 Code.
There was a problem hiding this comment.
The command still runs as claude auth login without the effective CLAUDE_CONFIG_DIR, so it does not log into a custom/inherited config directory. Describing that setting separately is not executable recovery guidance. Please provide an executable, safely quoted command targeting the effective config directory.
There was a problem hiding this comment.
The current instructions explicitly require setting the effective CLAUDE_CONFIG_DIR and running from the SDK query's working directory; running only the quoted login command is not the full instruction. The path/cwd tests verify that those values match the actual query. This avoids presenting POSIX assignment syntax as a command for every supported shell, but I agree that it is not a copy-paste command. I am reopening this discussion for human review of that usability tradeoff. No shell-specific command or credential recovery has been verified by this audit, and the PR remains unmerged. GPT 6 Astra via Codex in T3 Code.
There was a problem hiding this comment.
The current text describes those values but does not instruct users to set them. Would you like me to prepare a portable, executable recovery-guidance fix?
ApprovabilityVerdict: Not approved Macroscope's review found this PR not approvable — The PR changes production Claude authentication and quota failure handling, including when turns become failed and what recovery instructions users receive. Custom or inherited Claude configuration recovery guidance remains unsettled, so the authentication-sensitive behavior needs human review. Not approved because:
Adjust the Minimum Blocking Severity for this repo — including turning it Off — in Settings. You can add or adjust custom eligibility rules. Learn more. |
|
Fix first at f4338f0c. I independently reproduced #10320 in the actual Claude adapter from freshly fetched main a4953855, then ran identical event controls with this PR's exact two production files. Only the SDK query boundary was fake; completion came from the real adapter event stream, with no provider calls or live data.
Each run executed eight controls: main had the three expected reproduction failures; the proposal fixed those but failed the three preservation/recovery controls. The nested-assistant control passes because the existing parent-tool guard runs before this new latch. The listed-error review finding is confirmed. The 529 case also needs preserving, since The quota latch must stop diagnosing a recovered window. Same-window The inherited/configured-directory command findings also remain relevant after source review. I am preparing focused corrections on the existing PR; no duplicate PR, branch push or merge has been made by this audit. Actual CLI expiry/quota exhaustion and current client rendering remain outside this controlled adapter proof. Audited by GPT 6 Astra via Codex in T3 Code. |
Bugbot is paused — on-demand spend limit reachedBugbot uses usage-based billing for this team and has hit its on-demand spend limit. A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue. |
Rebased onto main: the failure hint now flows through resultOutcome and terminalResultError, which replaced the per-result error mapping upstream. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
14bb3fa to
d37f254
Compare
Success results carry no errors field in the SDK type, so CI typecheck rejected the listedError expression. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Bugbot is paused — on-demand spend limit reachedBugbot uses usage-based billing for this team and has hit its on-demand spend limit. A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue. |
…ic API error (pingdotgg#10321) Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
## What's Changed * fix(clients): show feedback results in composer banners by @juliusmarminge in pingdotgg/t3code#10398 * fix(server): stop Windows terminal polling from spiking CPU by @UtkarshUsername in pingdotgg/t3code#9476 * fix(web): onboarding installs agents without needing Node or npm by @t3dotgg in pingdotgg/t3code#10402 * fix(server): allow settling threads with unanswered async questions by @t3dotgg in pingdotgg/t3code#10400 * feat(ci): ship stable releases from the latest nightly commit by @t3dotgg in pingdotgg/t3code#10410 * feat(marketing): add a nightly channel to the download page by @t3dotgg in pingdotgg/t3code#10408 * fix(web): keep settings inputs focused during IME composition by @Lucenx9 in pingdotgg/t3code#10262 * fix(server): preserve Codex reset credits during usage updates by @yashranaway in pingdotgg/t3code#10308 * docs: link the repository security reporting policy by @yashranaway in pingdotgg/t3code#10303 * fix(web): only show auto balance errors after failed checks by @maria-rcks in pingdotgg/t3code#10407 * fix(web): improve preview recording frame delivery by @maria-rcks in pingdotgg/t3code#10403 * fix(server): preserve inline provider secrets on redacted saves by @maxwellyoung in pingdotgg/t3code#10054 * fix(web, mobile): replace Apple desktop machine labels by @extoci in pingdotgg/t3code#10396 * fix(web): hide browser when the right panel starts closing by @Neel2107 in pingdotgg/t3code#10385 * fix(web): keep settings section headings description-free by @maria-rcks in pingdotgg/t3code#10415 * fix(usage): read and redeem hub reset credits through CLIProxyAPI by @juliusmarminge in pingdotgg/t3code#10395 * fix(web): deduplicate expanded tool labels and keep errors expandable by @Yash-Singh1 in pingdotgg/t3code#10420 * fix(server): skip git status scans while the index is locked by @Gigioxx in pingdotgg/t3code#9845 * fix(mcp): allow text-only preview snapshots by @juliusmarminge in pingdotgg/t3code#10232 * fix(claude): name the expired login or usage limit instead of a generic API error by @vitalyiegorov in pingdotgg/t3code#10321 * feat(mobile): queue a message while its attachment is still uploading by @juliusmarminge in pingdotgg/t3code#10404 * feat(mobile): show when an existing thread has a message waiting in the outbox by @juliusmarminge in pingdotgg/t3code#10405 * fix(codex): accept misalignment policy errors on thread resume by @realbakari in pingdotgg/t3code#10373 * fix(server): skip disabled settlement lookups by @t3dotgg in pingdotgg/t3code#10424 * fix(server): run OpenCode CLI commands sequentially by @t3dotgg in pingdotgg/t3code#10427 * feat(web): name the drop action while dragging sidebar threads by @SunkenInTime in pingdotgg/t3code#10378 * perf(web): keep the sidebar responsive during bulk thread updates by @t3dotgg in pingdotgg/t3code#10413 * fix(web): onboarding wizard now supports light mode by @t3dotgg in pingdotgg/t3code#10432 * feat(threads): dismiss async questions without replying by @t3dotgg in pingdotgg/t3code#10431 * fix(web): stop collapsing the composer when it loses focus by @t3dotgg in pingdotgg/t3code#10437 * fix(server): keep interrupted threads resumable after restarts by @maria-rcks in pingdotgg/t3code#10421 ## New Contributors * @Neel2107 made their first contribution in pingdotgg/t3code#10385 * @realbakari made their first contribution in pingdotgg/t3code#10373 **Full Changelog**: pingdotgg/t3code@v0.0.39-nightly.20260906.1316...v0.0.39-nightly.20260907.1325 Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.0.39-nightly.20260907.1325
Closes #10320.
When Claude's OAuth session expires, or a subscription usage window rejects the request, the Claude CLI ends the turn with an opaque
terminal_reason: "api_error". T3 turned that into "Claude gave up after repeated API errors.", which reads as a provider outage when the real problem is a login or a quota.The adapter now latches the real cause during the turn and reports it when the turn ends as that generic API error, or as a success flagged
is_error:authentication_failedassistant event → "Claude is signed out: its login session expired. Runclaude auth loginin a terminal, then send the message again." The command namesCLAUDE_CONFIG_DIRwhen the instance uses a custom one.rate_limit_event→ "Claude usage limit reached. Send the message again once the limit resets." The existing warning row still shows the window and wait.The
is_errorsuccess case is included because the CLI sometimes ends an auth-failed turn assubtype: "success"with no terminal reason at all. Every other terminal reason keeps its own message, including a listed tool error or a context-window overflow, so a latched cause never hides a more specific one. The limit message omits the reset time because the wait was computed when the window rejected and is already on the warning row; recomputing it at result time would print a stale number.No retry behavior or provider status changes: the spawned CLI keeps its stale credentials until it is reaped, which is #9607 / #9628, so this PR only fixes the message. The turn fails the same way it does for other providers.
Before: a signed-out turn ends with the generic message.
After: the failed turn names the expired login and the sign-in command.
Related: #8869 covers the auth half with a probe-side inference this PR avoids. #7165 added the usage-limit warning row this builds on. #7878 and #7690 report adjacent auth symptoms; the stale CLI process after re-login stays with #9607 / #9628.
Verified with
vp test runon the touched files, server typecheck, targeted lint, and a real turn against a dev server with an empty Claude config dir.Implemented by Claude Fable 5.1 via Claude Code in T3 Code, with Opus and Sonnet subagents.
Note
Name expired login or usage limit instead of generic Claude API error
ClaudeTurnStatethat retains an authentication failure message and a set of rejected rate-limit window types, so the terminal result can use the specific cause rather than a genericapi_errormessage.claudeSignedOutMessagein ClaudeHome.ts which distinguishes subscription login from API-key auth and renders the configuredcwdandCLAUDE_CONFIG_DIRas encoded string literals.resultUserFacingErrorin ClaudeAdapter.ts to surface listed errors fromis_errorsuccess results and to prefer an authentication or usage-limit hint when the SDK provides no more specific terminal reason.is_errorClaude result whose turn recorded auth or rate-limit evidence now fails (status changes from completed to failed) with the specific message instead of completing; explicit terminal reasons still determine their own failure message.Macroscope summarized 451a65f.
Maintainer correction and current evidence
The correction at 451a65f7 preserves listed tool errors and HTTP 529 before using authentication or quota evidence as a generic-error fallback. Recovered quota windows no longer override a later API error; a different window that is still blocked remains reported. Warning deduplication is unchanged.
Authentication guidance now distinguishes subscription login from API-key configuration. It names the environment machine and the effective
CLAUDE_CONFIG_DIRand working directory passed to the SDK query, when a custom directory is present. Paths are literal prose, not an unquoted shell assignment. After subscription login it directs the user to a new thread because this PR does not restart the old CLI process.Verification by the maintainer audit:
is_errorsuccess without a reasonCurrent browser evidence
These are actual captured adapter output strings rendered by the real web client's unchanged error banner at 1280×900. The isolated environment contains four added projection-only visual fixtures; every provider is disabled. The adapter proof above and this rendering proof are separate checks, not a live authentication/retry test. The retained client is based on 3ae0fad3, with the banner, alert, tooltip and session contract unchanged through current main. ChatView has unrelated later changes, so this is not a full current-main client run. Native iOS, Android, Windows shells, actual credential expiry and exhausted account quotas were not exercised.
Before, authentication:
After, authentication:
Before, quota:
After, quota:
This remains unmerged for human review of authentication-sensitive recovery guidance. The correctness check passes. The recovery-guidance discussion is reopened for human review: the current text specifies the effective environment and working directory separately, while the follow-up review requests an executable command. That wording decision is not settled. Approvability remains neutral and must not be described as green. No retry, authentication-probe, provider-status, contract, or process-restart change is included.
Maintainer correction and verification by GPT 6 Astra via Codex in T3 Code.