fix(claude): fail turns when Claude Code is logged out #8869
main fromrefs/pull/8869/head·opened View on GitHubHuman review required#
This changes Claude authentication classification and remains held for a maintainer decision. It is not approved for automatic merging.
Claude can emit an explicit authentication_failed assistant event followed by a success-subtype result with is_error: true. Preserve the captured login hint and fail the errored turn. The provider probe also distinguishes a signed-out first-party CLI from API-key and external-provider configurations.
The current-main refresh fixes a compatibility gap in the original PR: terminal_reason: api_error already classifies the result as failed, so the old completed-only override discarded the login hint. The override now preserves that hint for failed results too. Interrupted, cancelled, and successful non-error results retain their existing behavior. This does not add a general is_error classification rule.
Related reports: #7690, #7878, #4225, and #6022. No issue is automatically closed by this PR. In particular, the original invisible-message symptom in #4225 has not been reproduced or demonstrated fixed.
Current-main verification#
- Original author head 51bf50e was merged with d7fe47f, preserving the author's commits. The provider conflict retains main's initialization/usage flow and the PR's API-key field; both user-guide sections remain.
- Before the repair, the author's actual adapter receipt test failed in 88ms. The emitted diagnostic was
Claude gave up after repeated API errors., without the promised login hint. - After d7ceee0, 151 focused adapter, capability-probe, and registry tests pass. This includes auth results with and without terminal metadata, plus interrupted, cancelled, successful non-error, and non-auth API-error controls.
- Server typecheck, targeted lint and cumulative diff checks pass. Current-head CI, correctness review, and Bugbot pass. The Approvability check is NEUTRAL, explicitly requiring human review of authentication behavior. It is not described as green. All review threads were read and none remain unresolved.
- The new proof uses fake SDK messages and typed completion receipts, not sleeps or a paid account. No provider login, logout, or generation was performed during this audit. Web, desktop, and mobile consume the unchanged server status/event contracts.
Original author's native-account evidence#
These existing images were inspected and preserved from the author's earlier revision. They are not a new current-main account run. The current refresh changes backend classification and diagnostic text, verified separately by the receipt tests above.
Before: the logged-out reply appears completed without an error.

After: the turn is failed and the login command is visible.

Before: Settings reports the signed-out CLI as authenticated.

After: Settings reports it as not authenticated.

Original implementation and native-account evidence by none23, using Claude Code. Current-main regression repair and audit by GPT 6 Astra via Codex in T3 Code.
Note
Medium Risk
Changes authentication detection and turn-completion overrides; misreading apiKeySource from the SDK could mark a valid session unauthenticated or miss a logout.
Overview
When Claude Code is logged out, the SDK can emit an authentication_failed assistant message and still finish the turn with a success result and is_error: true. ClaudeAdapter now records a login hint from that assistant event and, on the following error result that would otherwise look completed or a generic failed, forces the turn to failed with the shared CLAUDE_UNAUTHENTICATED_MESSAGE (including claude auth login guidance).
Provider status probing adds apiKeySource from the CLI init payload and treats first-party + tokenSource: "none" + no apiKeySource as logged out (Not authenticated), while API-key setups that also report tokenSource: "none" stay ready. User docs describe signing in again, including matching CLAUDE_CONFIG_DIR when the instance uses a custom config path.
Note
Fail Claude Code turns when logged out and surface unauthenticated provider status#
- Captures
authentication_failedassistant messages inClaudeAdapterturn state; when a subsequent error result resolves to completed or failed, the adapter overrides it to failed, emitsruntime.error, and uses the stored login guidance as the message. Interrupted and cancelled results are not overridden. - Adds an optional API-key source field to
ClaudeCapabilitiesProbeso provider status can distinguish an API-key setup from a logged-out first-party CLI.checkClaudeProviderStatusnow reports installed/error/unauthenticated with a login command when token source is none and no API-key source is present. - Adds docs in providers-claude.md covering the logged-out failure and login commands.
- Risk:
checkClaudeProviderStatusnew early-return branch in ClaudeProvider.ts could misclassify a first-party account if the SDK reports a token source the branch does not expect; verify that first-party API-key and unspecified-provider paths still resolve to ready/authenticated.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Approvability#
Verdict: Not approved
Macroscope's review found this PR not approvable — This focused fix changes production Claude authentication classification and turn-completion behavior for signed-out accounts. Because authentication-sensitive runtime behavior and SDK account-field interpretation are involved, maintainer review is warranted.
Not approved because:
- Monthly spending limit reached (workspace setting). Approvability relies on correctness review in order to determine eligibility
Codex Review Summary#
This comment shows the latest Codex review activity on this pull request.
Review Status Commit Review trigger 📝 Code Review ✅ Completed 2026-08-31T11:00:57.223009Z 59d6aa1Manual request ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review" or "@codex security review".
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.
💡 Codex Review#
Here are some automated review suggestions for this pull request.
Reviewed commit:
59d6aa1f04ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
apps/server/src/provider/Layers/ClaudeProvider.ts line 574Resolvedby none23(GitHub profile, opens in a new tab)@@ -948,3 +957,12 @@948957 });949958 }950959960+ // A logged-out first-party CLI still initializes and reports tokenSource961+ // "none" with no apiKeySource. Only that explicit combination counts as962+ // logged out: API-key setups report tokenSource "none" too but carry an963+ // apiKeySource, and external-auth backends (Bedrock, Vertex, gateways) and964+ // older CLIs that omit tokenSource keep their current status.965+ if (966+ capabilities.apiProvider === "firstParty" &&967+ capabilities.tokenSource === "none" &&968+ !capabilities.apiKeySourceNormalize the no-key sentinel before checking auth
When a logged-out first-party CLI reports the normal
apiKeySource: "none"sentinel (the repository's own Claude init fixture uses this exact representation), this condition is false because the nonempty string is truthy. The provider therefore still returnsstatus: "ready"andauth.status: "authenticated", so the new Settings behavior does not work for that payload. Treat"none"as an absent key source and cover that actual sentinel in the status test.Useful? React with 👍 / 👎.
COMMENT FROM claude-fable-5
This conflates two different
apiKeySourcefields.The fixture cited (
ClaudeAdapter.test.ts,apiKeySource: "none") is the per-turnsystem/initstream message (SDKSystemMessage.apiKeySource). That is not what this gate reads, and"none"is not a real value even there: the SDK enum is'user' | 'project' | 'org' | 'temporary' | 'oauth'; the fixture only compiles through anas unknown as SDKMessagecast.This gate reads
AccountInfo.apiKeySourcefrom the initialize control response, typedapiKeySource?: string. Probed against the real CLI (2.1.251): logged out, the field is absent; key-based auth reports"ANTHROPIC_API_KEY". No"none"sentinel has been observed on this payload.Treating
"none"as absent would be speculative handling of a value this field has never produced, and points the wrong way: if a future CLI emitted it for a working key setup, we would flip an authenticated provider to "Not authenticated", the exact false positive theapiKeySourceguard prevents. Even in the hypothetical where the probe misses a logged-out CLI, the turn itself still fails loudly through the adapter path, which does not consult the probe.none23(GitHub profile, opens in a new tab) changed the title
none23(GitHub profile, opens in a new tab) changed the title
Bugbot is paused — on-demand spend limit reached
Bugbot 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.
Closed as superseded by #10321.
juliusmarminge closed this
Reopened the remaining part as https://github.com/pingdotgg/t3code/pull/10469
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
7849efac-aa70-417a-85b3-f4c9c173fd9aYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.Use the checkbox below for a quick retry:
Warning
Your free Security trial is over. An organization admin can activate Security or dismiss this notice.
Comment `@coderabbitai help` to get the list of available commands.