Skip to content

config.toml content was reset in Codex (cc-switch)

Quick fix

Upgrade to v4.0.0+: older versions overwrote the entire config.toml, losing MCP and projects settings. Newer versions replace only key fields and preserve the…

Error output
此时config.toml中内容被重置了
English translation

At this point, the contents of config.toml have been reset.

Older versions of cc-switch overwrote ~/.codex/config.toml in full with a provider template or proxy_live_backup template when switching Codex providers, enabling or disabling local routing, or fully restarting the app. They did not merge changes incrementally. This caused user-defined [mcp_servers.*], [projects], [desktop], [features], [memories], color and UI settings, conversation session indexes, and model_provider to be lost or forcibly changed. Maintainers explained this as a legacy design: to prevent conflicts between provider-specific fields, the app originally used a “overwrite the config file plus a shared config fragment” approach.

The issue has several variants across versions: v3.11.0 had an overly restrictive allowlist that prevented shared config from being saved; v3.11.1 appended shared config indefinitely; some versions forcibly changed model_provider to "ccswitch"; when “Write shared config” was checked, the frontend reserialized the entire document with smol-toml, disrupting TOML table order; and v3.20.x forcibly overwrote requires_openai_auth (issue #7211 is still open). Also, MCP management settings took precedence over shared config, which could make shared config changes appear ineffective. The official fixes were: v3.12.2 introduced Section-Aware TOML editing, v3.13.0 fixed MCP preservation during provider switching, v3.17.0 moved merged writes to backend toml_edit, and v4.0.0 finally changed the behavior to replace only key fields such as routing, credentials, and models, while preserving all other content byte-for-byte.

  1. Upgrade to cc-switch v4.0.0 or newer (the current latest is v4.0.6): switching providers or entering and exiting local routing replaces only key fields such as routing, credentials, and models. MCP, [projects], comments, and other custom content are preserved byte-for-byte. Exiting no longer overwrites config.toml with an old backup. Download: https://github.com/farion1231/cc-switch/releases/latest

  2. Before upgrading, use a backup to recover lost settings: if config.toml has already been reset, restore the original MCP and projects settings from a backup file in ~/.codex/ or from a third-party tool (such as the user-shared Codex-Config-Guardian), then upgrade.

  3. If you cannot upgrade yet and use local routing or proxy mode (3.16.x), follow this order when changing MCP settings: first disable Codex local routing or proxy takeover in CC Switch and wait for the original configuration to be restored. Then enable, disable, or delete MCP entries in “MCP Management.” Confirm that ~/.codex/config.toml is correct, then re-enable local routing so CC Switch creates a new backup based on the latest configuration.

  4. When configuring MCP, add and enable it for Codex through cc-switch’s “MCP Server Management” page. Do not write it manually to config.toml, as it may be overwritten during a provider switch or restart. In older versions, MCP management settings took precedence over shared config, so keep the settings in both places consistent.

  5. The issue where requires_openai_auth is forcibly changed in v3.20.x (#7211) is not fixed yet. As a temporary workaround, use a script after switching providers to restore the desired requires_openai_auth value in config.toml, or wait for an official fix.

ToolCodex
Versioncc-switch 3.11.0 - 3.20.2 受影响(其中 model_provider 强制改写问题在 v3.16.0 修复,TOML 序列化乱序在 v3.17.0 修复,整份覆盖问题在 v4.0.0 彻底修复;requires_openai_auth 强制改写在 3.20.2 仍存在)
PlatformsWindowsmacOS
When is shared config written? Why does checking the option seem to have no effect?
Maintainers confirmed that writing shared config happens at the same time as switching providers. It is written as long as the new provider also has “Write shared config” checked. In older versions, the MCP Management page took precedence over shared config, which could make shared config changes appear to be overwritten; set both to match. Starting with v4.0.0, shared config fragments were removed, and global settings remain directly in config.toml.
After switching providers, my sessions, plugins, and conversation history are gone. Can I recover them?
The session files themselves usually were not deleted. More often, config.toml was overwritten and model_provider was forcibly changed to "ccswitch", so the Codex desktop app could not find the original session through the provider index, or the plugin marketplace URL was reset. You can manually change model_provider back to "OpenAI" to check for the history; v3.16.0+ no longer forcibly changes this field. If the plugins were cleared, configure the marketplace path again.
After enabling local proxy mode, deleted MCP entries return when I restart my computer. What should I do?
This is caused by the full-template overwrite issue in 3.16.x. As a temporary workaround, first disable Codex local routing and wait for the original configuration to be restored. Then make changes in MCP Management, confirm that config.toml is correct, and re-enable routing. Upgrade to v4.0.0+ for a permanent fix.
After saving, [projects] appears between [model_providers] and [model_providers.xxx]. Is the configuration broken?
Older frontend versions reserialized the entire document with smol-toml, disrupting table order. The TOML is still valid. v3.17.0 fixed this by switching to the backend toml_edit flow. As a temporary workaround, omit empty parent table headers (such as [model_providers]) from the configuration and write only the child tables.
In v3.20.2, requires_openai_auth is forcibly changed to false (or true) after switching providers, causing a 401. What should I do?
This issue (#7211) is still unresolved: CCS intentionally aligns requires_openai_auth with the authentication state observed by Codex itself. As a temporary workaround, use a script after switching to restore the desired value. If the provider uses experimental_bearer_token, requires_openai_auth = false is usually needed.
After upgrading to v4.0.0, do I still need to check “Write shared config”?
No. Starting with v4.0.0, shared config fragments and the related checkbox were removed. The editor displays the configuration file that will be used after switching. Global settings edited directly in it are written to the file; switching replaces only key fields and preserves the rest.

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.