Repository navigation
fix: prevent 401 errors from CLI-refreshed tokens being clobbered - #1286
Merged
Jinwoo-H merged 1 commit intoMay 1, 2026
Merged
Conversation
…stale managed auth Both CodexRuntimeHomeService and ClaudeRuntimeAuthService performed one-directional auth sync — copying managed credentials to the runtime path on every PTY launch and rate-limit fetch, but never reading back tokens that the CLI refreshed. When OAuth tokens expired and the CLI silently refreshed them, the next sync would overwrite the fresh tokens with the stale managed copy, causing intermittent 401 Unauthorized errors. Adds readBackRefreshedTokens() to both services: before overwriting runtime auth, compare the file to what Orca last wrote. If they differ, the CLI refreshed the token — write it back to managed storage first. Also adds detectExternalLoginAndUpdateSnapshot() to Codex (already existed on Claude side) and clearLastWritten*() methods to prevent re-auth flows from having their fresh tokens clobbered by stale read-back. Fixes #1284 Co-authored-by: Orca <[email protected]>
Jinwoo-H
force-pushed
the
Jinwoo-H/bug-claude-codex-accounts-intermittently-return
branch
from
May 1, 2026 05:16
ba1e5d4 to
2c80621
Compare
mralexsaavedra
pushed a commit
to mralexsaavedra/orca
that referenced
this pull request
May 2, 2026
…ablyai#1286) Co-authored-by: Orca <[email protected]>
4 tasks done
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
…ablyai#1286) Co-authored-by: Orca <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CodexRuntimeHomeServiceandClaudeRuntimeAuthServiceperformed one-directional auth sync — copying managed credentials to the runtime path on every PTY launch/rate-limit fetch, but never reading back tokens that the CLI refreshed401 Unauthorized/token_expirederrorsreadBackRefreshedTokens()to both services: before overwriting runtime auth, compare the file to what Orca last wrote; if they differ, the CLI refreshed the token — write it back to managed storage firstdetectExternalLoginAndUpdateSnapshot()to Codex (already existed on Claude side) for detecting externalcodex loginduring managed→system-default transitionsclearLastWritten*()methods to prevent re-auth/add-account flows from having fresh tokens clobbered by stale read-backTest plan
codex loginexternally while managed account active, then deselect → external login should persistFixes #1284
Made with Orca 🐋