Note
Grok responding on behalf of Julius.
Triage
Thanks for the detailed report and trace, @chrhicks! It made this easy to follow end to end.
What I found
Managed ChatGPT sign-in renews the saved access token, but conversation traffic keeps going through the app-server process that was started with the old token. Only a restart picks up the new one. This still happens on main (31f9d832).
CodexChatGptAuth.accessrefreshes when the saved token is within 60 seconds of expiry and writes the new tokens back (apps/server/src/provider/CodexChatGptAuth.ts).makeCodexManagedRuntimeputs that token in the child environment asACCESS_TOKENand returns it asrevision, but nothing readsrevisionafterward (apps/server/src/provider/CodexManagedRuntime.ts).CodexAdapterV2.openSessionresolves the runtime once and spawns app-server with that environment.startTurnreuses the client captured at open (apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts).- The registry's
withAccesswrapper only coversopenSession(apps/server/src/orchestration-v2/ProviderAdapterRegistry.ts). Provider status checks callwithAccess(runtime.resolve)separately (apps/server/src/provider/Drivers/CodexManagedProvider.ts), so Settings can renew credentials without touching the live process. ProviderSessionManagerkeeps returning the existing runtime for the same provider session (apps/server/src/orchestration-v2/ProviderSessionManager.ts). Sessions are released on sign-in and sign-out (ProviderAuthService.stopSessions), not on a silent refresh.
Your October 5 trace matches this. App-server was spawned at 16:05:28 with the earlier token, and turns failed with 401 token_expired at 16:22. The exchange succeeded at 16:28:32, but no new app-server was spawned, so the next turn failed the same way. After the desktop restart, thread/resume worked. Refreshing or toggling the provider doesn't release the session the manager is already holding, which is why that didn't help. Restarting T3 is the workaround for now.
This is separate from #14356, where the refresh request itself fails with invalid_grant, and from #11136, which is about switching an existing Codex CLI account.
Likely fix area
OpenAI's Codex app-server token-sharing guide describes this flow: refresh the token, restart app-server with the new ACCESS_TOKEN, initialize, then thread/resume the saved thread. Possible directions:
- Watch the runtime
revisionand restart the managed app-server and resume the thread when the token changes, including when a turn is already in flight. - Release the held provider session when a managed token refresh succeeds, so the next turn reopens with the new token.
A maintainer will decide on the fix direction.