Codex 切换官方 OAuth 账号后 app-server daemon 仍用旧 token
Author: spancerxingCreated Sep 26, 2026Updated Sep 28, 2026
Labelsbug
Self Checks / 自检
I have searched for existing issues, including closed ones. 我已搜索过已有的 Issue,包括已关闭的。
CC Switch Version / 版本号
3.20.4
Operating System / 操作系统
macOS
Related App / 涉及应用
Codex
Steps to Reproduce / 重现步骤
- 环境:cc-switch 3.20.4(macOS arm64)+ codex-cli 0.157.1(npm 安装)
- 在「认证中心」登录两个 ChatGPT 账号,分别绑定到两个 Codex「OpenAI Official」卡片
- 切到账号 A,打开终端运行 codex,正常
- 切到账号 B,再打开 codex → 登录的仍然是账号A
- ~/.codex/auth.json 内容也是正确的账号 B —— 文件层面切换是对的,但 codex 进程仍用旧账号
Expected Behavior / 期望行为
切换账号后,打开 codex 直接使用新账号
Actual Behavior / 实际行为
切换后打开 codex 继续用旧账号。 根因:codex 自带的 app-server 常驻 daemon(codex app-server --managed-daemon,npm 安装 codex 也会自动带上)把 OAuth token 缓存进内存,cc-switch 切换只改写 ~/.codex/auth.json,daemon 不重读,继续用旧的token。 执行 codex app-server daemon stop(或 pkill -f "codex app-server")后立即恢复正常。
Additional Context / 补充信息
- ~/.codex/config.toml 里 daemon_auto_start = false 只能阻止自启,解决不了"已运行的 daemon 缓存旧 token"的问题
- 建议:cc-switch 切换 Codex 官方 OAuth 账号后,检测并重启 app-server daemon(如调用 codex app-server daemon restart),或至少提示用户重启
Source: farion1231/cc-switch