Switching Codex providers overwrites config.toml
Quick fix
Upgrade cc-switch to v3.17.0+ and sync the MCP and other settings you want to keep into “General Configuration”; if an old snapshot still writes them back…
Symptom
Section titled “Symptom”`config.toml` 被重写后,Codex Desktop 相关配置丢失或被还原。After `config.toml` is rewritten, Codex Desktop-related settings are lost or reverted.
The common issue is that Codex stores MCP, plugin, features, desktop/windows preferences, and model/provider settings in `~/.codex/config.toml`, while cc-switch also rewrites this file when switching providers, taking over local routing after restart, or syncing from the database. Older versions rewrote the entire `config.toml` or provider snapshot (`providers.settings_config`), the `mcp_servers` table, and General Configuration together. As a result, only fields such as model/provider/base_url might remain, or deleted/changed `[mcp_servers.*]`, `[plugins.*]`, `[features]`, `[windows]`, and `[desktop]` sections might be restored. Issues #5149/#5049 involved lost plugins and desktop settings; #4697/#4699/#4856/#956 involved MCP entries revived from an old snapshot or MCP table; and #2844/#4713 involved session history and reconnection or login problems after the provider name or auth/config was rewritten.
The fixes vary by issue. Maintainers confirmed that General Configuration merging was unreliable and that nested table loss was fixed in v3.17.0 with a structured backend merge using `toml_edit`. In v3.17.0, live `[mcp_servers]` entries contaminating snapshots when switching away were also stripped, and already contaminated snapshots can self-heal the next time you switch away. However, maintainers said this only covers the provider-switching path: restarting without switching does not immediately self-heal, and proxy takeover or backup merging may still retain orphaned MCP entries. Issue #6344 still reported in 3.19.2 that the MCP panel toggle imports entries but does not write them. Some settings that appear ineffective are not caused by incorrect cc-switch writes: in #3548, maintainers confirmed `base_url` belongs under `[model_providers.<name>]`, not `openai_base_url`; #2614 showed that Codex reads the context window from the model catalog's `context_window`, not top-level `model_context_window`; and #4970/#4971/#3668 involved the desktop selector failing to render because of the model catalog, `models` array, or `openai_chat` format.
Back up `~/.codex/config.toml`, `~/.codex/auth.json`, and `~/.cc-switch/`, then upgrade cc-switch to v3.17.0 or later. Do not stay on 3.12.0/3.12.1, which clear configuration and show a database mismatch warning if you roll back. For session history or provider name issues, upgrade to at least v3.16.2.
Put Codex changes you need to keep in cc-switch’s “General Configuration” or the relevant provider template, rather than editing only the live `config.toml`. This includes `[mcp_servers.*]`, plugin and desktop preferences, and manual entries such as `web_search = "live"` that provider templates may overwrite.
If a deleted MCP entry reappears after saving, delete the matching entry in cc-switch’s “MCP Management” at the upper right and check whether old `[mcp_servers.*]` entries remain in each Codex provider configuration. Deleting only `~/.codex/config.toml` is not enough because the database or snapshots can write the entry back.
If you suspect an old provider snapshot is contaminated, on v3.17.0+ switch to another provider and then switch back to trigger self-healing that strips `[mcp_servers]` when switching away. If you only restarted cc-switch without switching, perform this switch manually.
If Codex Desktop plugins, Computer Use/Browser/Chrome, or `[desktop]`/`[windows]`/`[features]` settings were restored, add those sections to General Configuration before switching. The temporary workaround in #5049 was to import General Configuration manually; Claude already read it automatically, while Codex automation required a later version.
If `/model` or the desktop model dropdown is empty, confirm the provider apiFormat is `openai_responses`. With `openai_chat` and local routing, the catalog was generated but not displayed in Codex Desktop in #4970/#4971. As a temporary workaround, follow #3668 to manually add the `model` field and the provider’s `models` array, and sync `models_cache.json`.
~/.codex/config.toml [model_providers.deepseek]name = "deepseek"base_url = "http://127.0.0.1:15721/v1"wire_api = "responses"requires_openai_auth = truemodels = [{ model = "deepseek-v4-pro", display_name = "DeepSeek V4 Pro" },{ model = "deepseek-v4-flash", display_name = "DeepSeek V4 Flash" },]model_catalog_json = "cc-switch-model-catalog.json"If enabling “1M context” still shows 258k, do not rely only on top-level `model_context_window = 1000000`. Following #2614, use a custom catalog to set that model's `context_window` to 1000000; the default `effective_context_window_percent` of 95 will show about 950k.
~/.codex/config.toml model = "deepseek-v4-pro"model_provider = "custom"model_catalog_json = "/Users/luca/.codex/custom-models.json"model_auto_compact_token_limit = 900000If the MCP panel toggle still does not write to `~/.codex/config.toml` in 3.19.2 (#6344 is open), the temporary options are to maintain `[mcp_servers]` manually or use a bridging script to merge and write `enabled_codex=1`, while keeping entries not managed by cc-switch. Follow the issue for an official fix.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 21 real issues
- #3668CC-Switch 写入的 config.toml 和 model-catalog 格式不被 Codex 识别,导致 /model 不显示第三方模型
- #1440更新之后,所有配置都不写入,还会清除配置
- #5149[Bug] 切换 Codex 供应商会覆盖 config.toml,导致 Codex Desktop 的插件与桌面设置丢失
- #5049插件仍然无法在供应商切换后保留安装
- #2656codex通用配置问题
- #2614codex开启1m上下文失败
- #3356Codex 配置好供应商后点击启动后,无法覆盖config.toml,只有启用后,再重启软件才会写进去
- #956[Bug][macOS 26.2] Codex Provider 修改已保存,但切换后 MCP 配置被改回旧内容
- #3548关于codex的base_url配置
- #4856历史配置覆盖新配置
- #28443.15.0版本 会导致codex会话历史异常丢失
- #4317Codex配置覆盖问题(已关闭问题重复报告)
- #4970[Bug] openai_chat + routing: model catalog generated but Codex desktop doesn't display models
- #4971[Bug] openai_chat + routing: model catalog generated but Codex desktop doesn't display models
- #4468打开 codex 应用增强模式时,启动第三方 api,会有一套旧配置覆盖掉当前配置
- #4697[Bug] Codex 普通 MCP 配置会被旧 provider 快照/CCS MCP 表回写,导致用户修改失效
- #4699Codex 普通 MCP 配置会被旧 provider 快照/CCS MCP 表回写,导致用户修改失效
- #4713[Bug] 从 OpenAI Official 切换到第三方 Provider 再切回后 Codex 卡在重连/需重新登录
- #5430RFC: Codex Provider configuration ownership, session routing, model mapping, and outbound proxy / Codex Provider 配置所有权、会话路由、模型映射与出站代理
- #6344[Bug] Codex 的 MCP 服务器只有导入没有写入,面板开关不会写入 ~/.codex/config.toml
- #6556[Bug] Codex 桌面 App 使用第三方供应商时完全不提供 web_search 工具(同配置 CLI 正常)
- Does it matter whether “Write to General Configuration” is checked? What if only base_url remains either way?
- In #1440, a maintainer asked about this. The user confirmed that only base_url remained whether the option was checked or not, and that 3.12.0/3.12.1 could not even write General Configuration comments. This was an older-version write/clear issue. Upgrade to a fixed version, confirm General Configuration contains the intended settings, and do not roll back to an old version that reports a database mismatch.
- Where can I import settings into General Configuration manually? Is it under skills and MCP management?
- The answer in #5049 was to put new plugins and other configuration items into “General Configuration” manually so they enter the cc-switch database and persist across switches and restarts. New plugins on the Claude side were already read into General Configuration automatically; Codex automation was expected to be extended in a later version.
- Is base_url written to the wrong place? Doesn’t Codex recognize openai_base_url?
- #3548 was closed with no code change: cc-switch writes `base_url` under `[model_providers.<name>]` for Codex, which is the standard field for Codex model_providers. `openai_base_url` is not a field that cc-switch writes.
- Why does an MCP entry I deleted reappear after I save or switch providers?
- The common cause in #4856/#4697/#4699 is that copies remain outside the live configuration: the `providers.settings_config` snapshot, the `mcp_servers` table, or MCP Management may still contain the old entry. Delete it from MCP Management and the provider configuration in cc-switch, then switch away and back once on v3.17.0+ to self-heal contaminated snapshots.
- After switching back to OpenAI Official, why does it stay at “Reconnecting...” or ask me to log in again? Did preserveCodexOfficialAuthOnSwitch not help?
- #4713 reported that even with `preserveCodexOfficialAuthOnSwitch = true`, `config.toml` or `auth.json` could still be rewritten. The temporary options were to log in again or edit the configuration manually, but the issue could recur on the next switch. The issue is stale, and this path is still not fully resolved.
- Why is the desktop model selector still empty when the catalog file was generated and the proxy forwards requests normally?
- #4970/#4971 found that with `openai_chat` and local routing, the catalog was generated but Codex Desktop did not render it; only `openai_responses` worked. #3668 also listed three separate issues: a catalog entry missing the `model` field, a missing `models` array in `[model_providers]`, and an out-of-sync `models_cache.json`.
Related problems
Section titled “Related problems”This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.