**Codex Desktop does not preserve existing Projects/Chats when switching to an AI Gateway custom model provider**

Open 💬 1 comment Opened Jul 8, 2026 by chandancp

What version of the Codex App are you using (From “About Codex” dialog)?

26.623.141536

What subscription do you have?

Enterprise

What platform is your computer?

MAC and Windows

What issue are you seeing?

Environment

Product

  • Codex Desktop

Version

26.623.141536
Released Jul 6, 2026

Operating System

  • macOS 10.15.7 (Intel)
  • Windows 11

---

Summary

After configuring an AI Gateway as a custom model_provider in ~/.codex/config.toml and setting it as the active provider, Codex Desktop successfully routes inference requests through the AI Gateway. However, all previously created Projects and Chats disappear from the Desktop UI, even though the conversation data still exists locally.

The conversations are not deleted—they remain present in the local SQLite database and rollout session files—but the Desktop no longer displays them.

---

Configuration

Configured an AI Gateway as a custom provider.

Example:

[model_providers.ai_gateway]
name = "AI Gateway"
base_url = "https://<gateway-url>"
experimental_bearer_token = "<redacted>"

model_provider = "ai_gateway"

No other configuration changes were made.

What steps can reproduce the bug?

---

Steps to Reproduce

  1. Install Codex Desktop.
  2. Create several Projects and Chats using the default OpenAI provider.
  3. Verify that all Projects and Chats are visible.
  4. Configure an AI Gateway as a custom model_provider.
  5. Set the active provider:
model_provider = "ai_gateway"
  1. Restart Codex Desktop.

---

What is the expected behavior?

Expected Behavior

Changing the model provider should only change the inference endpoint.

Existing local Projects and Chats should remain visible regardless of which compatible model provider is selected.

---

Additional information

Actual Behavior

After restarting Codex Desktop:

  • Requests are successfully routed through the AI Gateway.
  • Existing Projects disappear from the sidebar.
  • Existing Chats disappear.
  • New conversations created using the AI Gateway are displayed normally.

No local conversation history is deleted; it simply becomes inaccessible from the Desktop UI.

---

Investigation Performed

The following was verified during troubleshooting.

1. Conversation history still exists

Verified under:

~/.codex/sessions/

All rollout JSONL files remain present.

---

2. Thread metadata still exists

Verified using:

SELECT
    id,
    title,
    cwd,
    rollout_path,
    model_provider
FROM threads;

Historical conversations remain in state_5.sqlite.

---

3. Session metadata contains the model provider

Each rollout contains a session_meta record similar to:

{
  "type": "session_meta",
  "payload": {
      "model_provider": "openai"
  }
}

---

4. Provider metadata was updated

For testing, all rollout files were updated from:

model_provider = "openai"

to

model_provider = "ai_gateway"

and verified.

---

5. SQLite metadata was updated

Updated:

UPDATE threads
SET model_provider='ai_gateway';

and confirmed all rows reflected the new provider.

---

6. Desktop rebuilt the thread index

After restarting Codex Desktop, the application regenerated parts of the thread metadata, indicating that the Desktop rebuilds or refreshes its local thread index during startup.

---

7. Existing Projects still do not appear

Even after updating:

  • rollout session metadata
  • SQLite thread metadata
  • active provider configuration

the previously created Projects and Chats were still not displayed.

---

Observations

This suggests that Codex Desktop maintains additional project indexing or provider association metadata that is not migrated when switching from the default OpenAI provider to a custom AI Gateway provider.

The underlying conversation data remains intact, but the Desktop UI no longer associates those conversations with the active provider.

---

Impact

Organizations deploying an AI Gateway cannot seamlessly migrate existing local Codex Desktop history.

Users appear to lose all previous Projects and Chats after changing providers, even though the data remains on disk.

This creates a poor migration experience and may discourage adoption of AI Gateway deployments.

---

Suggested Improvements

Option 1 (Preferred)

Automatically migrate existing local Projects and Chats when switching providers.

---

Option 2

Provide a migration workflow.

Example:

The active model provider has changed.

Would you like to migrate your existing
Projects and Chats to the new provider?

[Yes] [No]

---

Option 3

Provide a supported CLI/Desktop command.

Example:

codex migrate-provider

or

codex rebuild-index

---

Option 4

If provider-specific history is the intended behavior, document it clearly and provide guidance for migrating or accessing previous conversations.

---

Why I Believe This Is a Bug

The configured model provider determines where model inference requests are sent. It should not hide or invalidate existing local conversation history.

Since:

  • conversation sessions remain on disk,
  • thread metadata remains in SQLite,
  • inference through the AI Gateway functions correctly,

the issue appears to be in how Codex Desktop rebuilds or associates Projects and Chats after a provider change, rather than a loss of user data.

---

Attachments

Include:

  • Sanitized config.toml
  • state_5.sqlite query results
  • Sample rollout session_meta
  • Before/after screenshots of the Projects sidebar
  • Codex Desktop version
  • Minimal reproduction steps

---

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗