codex-auth switch 目前只替换磁盘上的 auth.json,但 Codex CLI 进程在内存中持有旧账号的 OAuth refresh token(由 rmcp transport worker 维护)。由于 OpenAI 实施了 refresh token rotation + reuse detection,内存中的 stale token 一旦被后台触发刷新,会导致旧账号 token_invalidated 被踢下线。
建议在 codex-auth switch 执行前,原生加入以下逻辑:
检测是否有存活的 codex 进程(pgrep -f codex)
如果有,graceful 发送 SIGTERM,等待最多 1 秒
若未退出则 SIGKILL
再执行 auth.json 替换
这样用户就不需要在外面手动
[csw] Stopping Codex/auth/rmcp processes...
[csw] Switching to account: XXXX
[csw] Done. Start a new Codex session after this switch.
codex-auth switch 目前只替换磁盘上的 auth.json,但 Codex CLI 进程在内存中持有旧账号的 OAuth refresh token(由 rmcp transport worker 维护)。由于 OpenAI 实施了 refresh token rotation + reuse detection,内存中的 stale token 一旦被后台触发刷新,会导致旧账号 token_invalidated 被踢下线。
建议在 codex-auth switch 执行前,原生加入以下逻辑:
检测是否有存活的 codex 进程(pgrep -f codex)
如果有,graceful 发送 SIGTERM,等待最多 1 秒
若未退出则 SIGKILL
再执行 auth.json 替换
这样用户就不需要在外面手动
[csw] Stopping Codex/auth/rmcp processes...
[csw] Switching to account: XXXX
[csw] Done. Start a new Codex session after this switch.