[Bug]: Switching Codex accounts with `codex login` is not picked up by the running shared app-server; every turn fails with 'access token could not be refreshed'#23720
Before submitting
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area
apps/server
Steps to reproduce
- Run headless
t3 serveas a systemd user service with Codex signed in with ChatGPT (account A), and run a Codex thread so the sharedcodex app-serveris up. - Account A hits its usage limit. On the same host, run
codex loginand sign in with a different ChatGPT account (account B).~/.codex/auth.jsonnow holds account B. - Send another message in the existing thread, or start a new Codex thread.
Expected behavior
T3 picks up the new sign-in, either by reloading auth in the running app-server or by restarting it, and the turn runs on account B.
Actual behavior
The shared app-server keeps account A's tokens in memory. Every turn fails with:
Your access token could not be refreshed because you have since logged out or signed in to another account. Please sign in again.
(codexErrorInfo: "unauthorized"). Remote compaction fails the same way. Nothing in T3 shows that the running Codex session is stale, and T3 gives no way to restart or re-auth the provider.
The obvious way out is to kill the codex app-server process. That then runs into #16502: T3 doesn't notice the SIGKILL, and every following turn fails in ensureThread with read-process-exit-status until the T3 server is restarted.
codex exec and a freshly started codex app-server on the same host both work on account B straight away (account/read returns account B, and a turn completes), so the stored sign-in is fine. Only the long-lived shared app-server is stale.
Seen on two hosts the same day. On each, the new sign-in was written at 15:41 and 15:52 UTC, and the shared session kept failing until 16:17 and 16:03 UTC, when it was killed.
Impact
Blocks work completely (for Codex, until the T3 server restarts)
Version or commit
T3 Code 0.1.1 (stable)
Environment
Ubuntu (x86_64), headless t3 serve as the t3code.service systemd user service, Codex CLI 0.163.0 (npm global install, default Codex home), ChatGPT sign-in (Plus), GPT-6.1 Sol
Logs or stack traces
| 1 | # provider event log, after `codex login` switched accounts |
| 2 | incoming method=error "Your access token could not be refreshed because you have since logged out or signed in to another account. Please sign in again." codexErrorInfo=unauthorized |
| 3 | incoming method=error "Error running remote compact task: Your access token could not be refreshed because ..." |
| 4 | incoming method=turn/completed status=failed |
| 5 | |
| 6 | # T3 server, after killing the stale app-server (same as #16502) |
| 7 | WARN Orchestration effect execution failed effectType: 'provider-turn.start' attemptCount: 4 |
| 8 | [cause]: ProviderAdapterEnsureThreadError: Failed to ensure codex provider thread for app thread ... |
| 9 | [cause]: CodexAppServerTransportError: Codex App Server transport operation 'read-process-exit-status' failed. |
| 10 | [cause]: Error: Process interrupted due to receipt of signal: 'SIGKILL' |
Workaround
After codex login, restart the T3 server (systemctl --user restart t3code). Don't kill the app-server.
Related: #16502