VS Code extension keeps switching from ChatGPT Plus auth to API key / Codex mode

Open 💬 3 comments Opened Apr 9, 2026 by apoapostolov
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

Problem

For the last 2-3 days, the VS Code Codex extension has started forgetting my ChatGPT Plus subscription state and switching me to API-key/Codex auth. It then repeatedly asks me to relogin before it will use the ChatGPT Plus subscription again.

What I expected

  • Stay on my ChatGPT Plus subscription session
  • Keep using subscription-backed auth unless I explicitly switch providers
  • Not require constant relogin to get back to the subscription mode

What actually happens

  • Extension silently flips to API key / Codex mode
  • It forgets the ChatGPT Plus subscription state
  • I have to relogin over and over to return to using the subscription

Environment

  • VS Code Codex extension
  • ChatGPT Plus subscription
  • Started happening recently, around the last 2-3 days

Impact

This makes the extension unreliable because the auth state is not sticky and the extension does not preserve the subscription-backed session between launches or during normal use.

Notes

This is different from a simple 401 or one-off login failure. The issue is that the extension keeps reverting away from my ChatGPT Plus session and into API-key/Codex behavior without me asking for that.

View original on GitHub ↗

3 Comments

github-actions[bot] contributor · 4 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #17016
  • #16894

Powered by Codex Action

etraut-openai contributor · 4 months ago

I'm familiar with the auth code in the extension, and I can't think of any way that it could "switch you to API-key" without some action on your part. Is there any chance you have a script (or an agent) that's modifying the ~/.codex/auth.json file on disk?

This is also the first time we've received any report of this, so I don't think this is a widespread issue.

apoapostolov · 4 months ago

I checked my local auth file and here is the sanitized diagnostic information from it.

I am not posting any raw tokens publicly, but I can provide more details privately if needed.

Local auth file

  • Path on this machine: C:\Users\theap\.codex\auth.json
  • File exists
  • File size: 4334 bytes
  • Creation time: 2026-02-15 06:09:51

Safe fields from auth.json

  • auth_mode: chatgpt
  • OPENAI_API_KEY: null
  • account_id suffix: ...45e405

Safe decoded token metadata

From the currently persisted tokens (decoded locally, not verified, and only non-secret fields listed):

  • id_token.auth_provider: password
  • id_token.email_verified: true
  • id_token.chatgpt_plan_type: plus
  • access_token.chatgpt_plan_type: plus
  • access_token.chatgpt_compute_residency: no_constraint
  • access_token.session_id suffix: ...oqIRLt6C

Reproduction / behavior details

I probably did not explain the issue clearly the first time. The problem started after updating to VS Code 1.115.

Before that update, I was already logged in with my ChatGPT Plus subscription. The model selector showed my last used model normally, and prompts returned responses as expected.

After the update, the last used model now appears as Custom, and GPT-5.4-Mini is no longer shown there. When I try to prompt, I get 5 Reconnecting system messages, followed by stream disconnected.

In Settings, I now see two account-related options:

  • Logged in with API Key, followed by Use Copilot account
  • Logged in with Copilot, followed by Use OpenAI account

In practice, both paths lead to the same result: the same 5 Reconnecting messages, and the prompt never completes.

The only temporary workaround I have found is to log out and then log back in with my ChatGPT account via the browser OAuth flow. After that, the session works again, but only until I close the VS Code window. Once I open another window or start a new session, the same problem returns.

Important clarification

The problem itself started about 2 days ago after updating to VS Code 1.115.

About external modification

You asked whether a script or agent might be modifying ~/.codex/auth.json.

I do not intentionally have anything that should be rewriting it, and I searched my current workspace for references to .codex/auth.json / auth.json and found no matches.

If useful, I can also capture:

  • the exact VS Code extension version
  • whether the file changes immediately after browser OAuth login
  • whether the broken state happens with all other VS Code windows fully closed first