Repository navigation
Description
Summary
On Windows 11, the Anthropic OAuth account remains present after every reboot, but it is marked as needing reauthentication and all Anthropic models disappear from the model list.
The dashboard still shows the Anthropic provider as active and OAuth as logged in, while the account row has a yellow indicator and a Re-login button. Removing the account and adding it again immediately restores the Anthropic models, but the same problem returns after the next Windows reboot.
Expected behavior
The persisted Anthropic refresh token should be used after OpenCodex starts again, and Anthropic models should remain available without removing and re-adding the account.
Actual behavior
- Provider remains configured and active.
- OAuth status reports logged in.
- The active account is present but has
needsReauth: true. /api/modelsreturns zero Anthropic models.- The provider connectivity test treats Anthropic as not logged in.
- Deleting and reconnecting the account restores the models until the next reboot.
Reproduction
- On Windows 11, start OpenCodex with
ocx start. - Open
http://localhost:10100/. - Add an Anthropic account through Log in with your Claude account.
- Confirm that Anthropic models appear and work.
- Reboot Windows.
- Run
ocx startagain and open the dashboard. - Observe:
- Anthropic provider is still shown as active/OAuth.
- The account row has a yellow status dot and a Re-login button.
- Anthropic models are absent from the model list.
- Delete the Anthropic account and add it again.
- Observe that the models reappear immediately.
This has happened consistently after reboots in this environment.
Logs and diagnostics
Current post-reboot state, collected from the local management API and redacted:
opencodex: 2.7.26
codex-cli: 0.144.5
node: v24.15.0
GET /api/oauth/status?provider=anthropic
loggedIn: true
GET /api/oauth/accounts?provider=anthropic
accountCount: 1
activeAccountIdPresent: true
active: true
needsReauth: true
GET /api/models
anthropicModelCount: 0
POST /api/providers/test?name=anthropic
ok: false
latencyMs: 0
error: "static catalog only — upstream not verified (not logged in)"
Redacted auth-store metadata:
source: local-cli
hasAccessToken: true
hasRefreshToken: true
accessTokenExpired: true
Dashboard visual state: Anthropic provider is active, the single account row has a yellow status dot, and the Re-login action is shown.
No tokens, account IDs, email addresses, or other personal data are included.
Area
Provider adapter / Anthropic OAuth token persistence and refresh across process or OS restart.
Version
@bitkyc08/opencodex 2.7.26
OS
Microsoft Windows 11 Home, version 10.0.26200, 64-bit
Config shape
{
"provider": "anthropic",
"adapter": "anthropic",
"baseUrl": "https://api.anthropic.com",
"defaultModel": "claude-sonnet-5",
"authMode": "oauth",
"disabled": false
}Checks
- I searched existing open and closed issues first.
- I removed secrets, tokens, account identifiers, email addresses, and personal data.
Activity
fix(oauth): generation-safe Anthropic refresh + structured token erro…
docs(devlog): merge-readiness review of 6 issue patches (2 blockers: #…
fix(oauth): durable generation-bound refresh intent prevents Anthropi…
docs(devlog): record #202/#209 fixes + push + green CI (pre-merge rep…
Wibias commentedon Jul 21, 2026
Thanks for the detailed diagnostics - this made tracking down the root cause much easier.
What's happening
The
needsReauth: trueflag was being written toauth.jsonand reloaded on every process start. After a reboot, Windows often doesn't have network connectivity yet whenocx startruns. The first refresh attempt for the (expired) Anthropic access token then hits a network error,isTerminalRefreshErrormatches it, the account is markedneedsReauth: trueon disk, and from that point on every subsequent start skips the refresh entirely - the account is permanently locked until you remove and re-add it (which clears the flag by writing fresh credentials).The fix
PR #221 moves
needsReauthto an in-memory-only Set that starts empty on every process start. Within a session it behaves exactly as before - a confirmed terminal failure (revoked/rotated grant) still marks the account and the guardian skips it. But the mark never survives a restart, so a transient boot-time network error can't permanently lock a valid account. On the nextocx startthe refresh is retried with the still-valid refresh token and succeeds normally.The fix is in
src/oauth/store.ts:normalizeAccountno longer copiesneedsReauthfrom the JSON file;getAccountSetoverlays the in-memory markers when returning accounts; all the credential-save and account-remove paths clear the in-memory key on success.lidge-jun commentedon Jul 21, 2026
v2.7.31에 수정 반영했습니다. Anthropic refresh 오류를 구조화하고 generation-safe refresh 및 durable refresh intent로 재부팅과 stale-lock 경합 시 잘못된 token replay를 막았습니다. 반영 커밋: a626a5b, 0de138a
fix(oauth): generation-safe Anthropic refresh + structured token erro…
docs(devlog): merge-readiness review of 6 issue patches (2 blockers: l…
fix(oauth): durable generation-bound refresh intent prevents Anthropi…
docs(devlog): record lidge-jun#202/lidge-jun#209 fixes + push + green…