Skip to content

Resuming legacy openai_http Desktop threads returns 401 while new openai threads work #41273

Description

@cxy7988

What version of Codex is running?

  • Installed CLI: codex-cli 0.150.1
  • Affected persisted thread was created by Codex Desktop / CLI 0.146.1
  • A new working thread in the same Desktop/app-server process was created by CLI 0.149.1
  • Auth mode: ChatGPT (codex login status reports Logged in using ChatGPT)

What platform is your computer?

Ubuntu 22.04.5 LTS, Linux 6.8.0, x86_64. Codex Desktop is driving a local/SSH-style app-server session (source = "vscode" in persisted thread metadata).

What issue are you seeing?

An older Desktop thread can be read successfully, but every new prompt in that thread fails with:

unexpected status 401 Unauthorized: {"detail":"Unauthorized"},
url: https://chatgpt.com/backend-api/codex/responses

At the same time, a newly created thread in the same app-server process, with the same ChatGPT account and workspace, sends prompts successfully.

The key persisted metadata difference is:

affected old thread: model_provider=openai_http, cli_version=0.146.1
working new thread:  model_provider=openai,      cli_version=0.149.1

The legacy provider is still present in config.toml:

[model_providers.openai_http]
name = "OpenAI HTTP only"
wire_api = "responses"
supports_websockets = false
startup_timeout_sec = 60

It has no custom base_url or API-key environment variable and historically used ChatGPT authentication. The affected installation contains many persisted threads with this legacy provider name.

Local logs have also reported token_revoked / token_invalidated for the legacy request path, even though the current login status is valid and new openai threads work. This suggests that resume preserves a legacy/custom provider route whose OAuth/token refresh context is no longer compatible with the current built-in ChatGPT provider.

The failure is isolated to turn submission. SQLite integrity checks pass, persisted messages are readable, and the current thread works, so this is not a general network, account-plan, or history-database failure.

What steps can reproduce the bug?

  1. Configure a provider alias equivalent to the old HTTP-only OpenAI route:
    [model_providers.openai_http]
    name = "OpenAI HTTP only"
    wire_api = "responses"
    supports_websockets = false
  2. Sign in with ChatGPT and create a Desktop conversation using model_provider = "openai_http" on an older Codex version.
  3. Upgrade Codex/Desktop so newly created ChatGPT threads use the built-in model_provider = "openai".
  4. Confirm codex login status reports a valid ChatGPT login and that a new openai thread works.
  5. Open the persisted openai_http thread and submit a follow-up prompt.
  6. Observe repeated POST failures to /backend-api/codex/responses with HTTP 401 {"detail":"Unauthorized"}.

What is the expected behavior?

Resuming a persisted thread should remain usable after upgrading Codex.

If a legacy provider alias represents the built-in ChatGPT/OpenAI route, Codex should either:

  • migrate or normalize it to the current built-in openai provider;
  • refresh/rebind authentication correctly for the persisted provider; or
  • show an actionable provider/auth migration error before submitting the turn.

It should not display the history normally and then fail every follow-up with a generic 401 while new threads work under the same login.

Additional information

The persisted provider is present both in state_5.sqlite:threads.model_provider and the rollout session_meta.payload.model_provider. Manually rewriting both locations may be a workaround, but it is risky for long sessions containing provider-bound encrypted content and should not be required.

Related issues:

Request IDs, account identifiers, thread identifiers, local usernames, and absolute paths have been omitted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    appIssues related to the Codex desktop appauthIssues related to authentication and accountsbugSomething isn't workingcustom-modelIssues related to custom model providers (including local models)sessionIssues involving session (thread) management, resuming, forking, naming, archiving

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions