fix(server): respawn Claude sessions after re-login on expired credentials #9628
ClosedApexYash11(GitHub profile, opens in a new tab)wants to merge 2 commits into
main fromrefs/pull/9628/headopened View on GitHubgithub-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
- apps/server/src/provider/Layers/ClaudeAdapter.ts line 3129Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -3070,0 +3108,21 @@3108+3109+ // The CLI loads OAuth credentials once per process. An auth failure means3110+ // this process can never recover, and leaving it in place makes every3111+ // later turn reply "Not logged in" even after the user logs in again.3112+ // Closing the query ends the stream, so handleStreamExit tears the session3113+ // down; the next turn then goes through the normal resume-thread recovery,3114+ // which spawns a fresh process with current credentials. Interrupted and3115+ // cancelled turns are left alone: the flag may be stale relative to a3116+ // user-initiated stop.3117+ const authenticationFailed =3118+ context.authenticationFailed ||3119+ (message.is_error === true &&3120+ (isClaudeAuthenticationErrorText(resultErrorsText(message)) ||3121+ isClaudeAuthenticationErrorText(errorMessage ?? "")));3122+ if (authenticationFailed && status !== "interrupted" && status !== "cancelled") {3123+ yield* Effect.logInfo("claude.session.stopping-after-auth-failure", {3124+ threadId: context.session.threadId,3125+ turnStatus: status,3126+ detectedFrom: context.authenticationFailed ? "assistant-snapshot" : "result",3127+ });3128+ yield* Effect.try({
- @@ -4499,3 +4580,4 @@44994580 lastAssistantUuid: resumeState?.resumeSessionAt,45004581 lastThreadStartedId: undefined,45014582 stopped: false,4583+ authenticationFailed: false,
juliusmarminge added labelsmacroscope-review
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) reviewed