Skip to content

Codex config.toml configuration lost after switching provider - CC Switch

Quick fix

Upgrade cc-switch to v3.17.0+, which changes to incremental merge instead of full overwrite of config.toml.

Error output
codex 切换供应商 config.toml 被重置
English translation

codex switch provider config.toml is reset

When switching Codex providers or restarting the local router, early versions of cc-switch used a full replacement logic to write `config.toml`, causing user-defined non-provider fields such as MCP servers, sandbox configurations, and desktop preferences to be overwritten and lost. Additionally, early versions had defects in handling TOML, such as `base_url` being incorrectly written into the `[windows]` section, general configurations being infinitely duplicated, and `model_provider` being forcibly changed to `ccswitch`, causing historical sessions to disappear.

Starting from v3.12.2, Section-Aware TOML Editing was introduced to fix field position errors and duplication issues; v3.13.0 fixed MCP configuration loss during switching; v3.16.0 resolved the issue of forcibly overwriting `model_provider`; v3.17.0 moved the merge and write-back to the backend `toml_edit` process, implementing incremental merge to preserve non-provider fields. Some users reported that after v3.17.0, specific configurations (such as `node_repl`, color settings) were still being restored after restart, indicating that overwrite issues in edge cases may still exist.

  1. Upgrade cc-switch to v3.17.0 or higher. This version refactored the merge and write-back logic for Codex general configurations, changing to incremental merge, which only overwrites provider-related fields and preserves user-defined sections.

    ~/.codex/config.toml
    # 保留 [mcp_servers.*], [desktop], [features] 等用户配置段
  2. If using an older version (such as v3.12.x) and encountering `base_url` being written to the wrong location or general configurations infinitely increasing, upgrade to v3.12.2+, which fixes Section-Aware TOML Editing.

    ~/.codex/config.toml
    [model_providers.custom]
    name = "custom"
    wire_api = "responses"
    base_url = "https://your-api-url/v1" # base_url 正确写入对应供应商段下
  3. For MCP configurations, do not manually write them into `config.toml`. Add and enable them to Codex through cc-switch's "MCP Server Management" interface to avoid being overwritten.

    # 通过 cc-switch UI 管理 MCP,而非手动编辑 ~/.codex/config.toml
  4. If `model_provider` is forcibly changed to `ccswitch` after switching providers, causing historical sessions to disappear, upgrade to v3.16.0+, which implements Codex Live Config Preservation and no longer forcibly rewrites this field.

  5. If specific configurations (such as `js_repl`, color settings) are still restored after restart following an upgrade, check if local routing is enabled. The live/backup rebuild of local routing may still overwrite some configurations. Try disabling local routing or manually modifying the `original_config` field in the database `proxy_live_backup` table as a temporary workaround.

ToolCodex
Version3.10.2 - 3.20.0
PlatformsWindowsmacOS

This page is distilled from 40 real issues

Why does my manually added MCP configuration in config.toml disappear after switching providers?
Early versions of cc-switch used full replacement logic to overwrite config.toml when switching providers. Upgrade to v3.17.0+, or manage MCP configurations centrally through cc-switch's "MCP Server Management" interface to avoid manual writes being overwritten.
After upgrading to the latest version, why do node_repl or color settings still revert to false after restarting Codex?
Although v3.17.0 moved the merge logic to the backend toml_edit, the live/backup rebuild of local routing may still overwrite some edge configurations. If you encounter this issue, try disabling local routing, or manually modify the original_config field in the database proxy_live_backup table as a temporary workaround.
After switching providers, all historical session records in Codex disappeared. How to recover?
This is because old versions of cc-switch forcibly changed model_provider in config.toml to ccswitch, and Codex reads session records based on this field. Upgrade to v3.16.0+ to avoid this issue. For already lost records, manually change model_provider back to the original value (e.g., OpenAI) to attempt recovery.
base_url was written under the [windows] section, causing Codex to be unable to read it. How to fix?
This is a known bug in v3.12.0, fixed in v3.12.2. After upgrading to the latest version, base_url will be correctly written under the corresponding provider's section, such as [model_providers.custom].
After checking "Write general configuration", the configuration content infinitely duplicates. What to do?
This is a defect in the TOML merge logic of early versions, which did not perform Section-Aware processing. It has been fixed in v3.12.2, and upgrading will resolve it.
Cannot see custom models in Codex Desktop, only official models. What to do?
This may be related to Codex Desktop's local cache or path resolution. Try completely exiting Codex Desktop and reopening it, or reinstall/upgrade Codex Desktop. Also check if model_catalog_json and ~/.codex/cc-switch-model-catalog.json exist in ~/.codex/config.toml.
After enabling local routing, the opus model in Claude Code CLI always shows opus4.8 instead of the configured opus5?
After enabling local routing, cc-switch overwrites the default_opus_model field in config.toml. This is currently a known issue; disabling local routing can restore normal display. Wait for an official fix.
After saving the provider configuration, the displayed key is another provider's key. How to fix?
This is a known issue in v3.20.0, where the edit box prioritized reading the key from the shared auth.json, causing cross-contamination. It has been fixed in v3.20.1, changed to rebuild from the provider's own bearer token in config.toml. Contaminated keys before the fix need to be manually re-entered.

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.