fix(codex): add multi-platform CLI discovery and static gpt-5.5 template fallback#3382
Merged
farion1231 merged 2 commits intoMay 31, 2026
Conversation
…ate fallback for model catalog generation When cc-switch generates a Codex model catalog for third-party providers, it needs the gpt-5.5 model definition as a template. Previously it relied on either ~/.codex/models_cache.json (only exists when Codex has connected to OpenAI) or running 'codex debug models --bundled' (fails when codex is not on the Tauri app's PATH, common in macOS GUI environments). This commit adds a three-tier fallback: 1. Try 'codex' from PATH, then platform-specific common paths (/opt/homebrew/bin/codex, /usr/local/bin/codex, etc.) 2. If all CLI attempts fail, use a compile-time embedded gpt-5.5 template (extracted from codex 0.135.0 bundled models) Also adds tests for the static template validity and CLI candidates.
Contributor
Author
|
我已对该修改进行审查,应该能解决像我这种从未直连过OpenAI的人的问题。 其实我就是因为看到ccswitch现在支持转发deepseek才第一次愿意尝试codex。相信有更多的人也是怀着同样的心情打开cc-switch,然后被这个问题卡了一下午。 希望cc-switch越来越好~ |
Owner
|
@codex review |
|
thanks,感谢 终于找到了 |
AnXiYiZhi
pushed a commit
to AnXiYiZhi/DevCLaw-old
that referenced
this pull request
Jun 9, 2026
…ate fallback (farion1231#3382) * fix(codex): add multi-platform CLI discovery and static gpt-5.5 template fallback for model catalog generation When cc-switch generates a Codex model catalog for third-party providers, it needs the gpt-5.5 model definition as a template. Previously it relied on either ~/.codex/models_cache.json (only exists when Codex has connected to OpenAI) or running 'codex debug models --bundled' (fails when codex is not on the Tauri app's PATH, common in macOS GUI environments). This commit adds a three-tier fallback: 1. Try 'codex' from PATH, then platform-specific common paths (/opt/homebrew/bin/codex, /usr/local/bin/codex, etc.) 2. If all CLI attempts fail, use a compile-time embedded gpt-5.5 template (extracted from codex 0.135.0 bundled models) Also adds tests for the static template validity and CLI candidates. * fix(codex): discover user node codex installs --------- Co-authored-by: Jason <[email protected]>
gfunc
pushed a commit
to gfunc/cc-switch
that referenced
this pull request
Jun 19, 2026
…ate fallback (farion1231#3382) * fix(codex): add multi-platform CLI discovery and static gpt-5.5 template fallback for model catalog generation When cc-switch generates a Codex model catalog for third-party providers, it needs the gpt-5.5 model definition as a template. Previously it relied on either ~/.codex/models_cache.json (only exists when Codex has connected to OpenAI) or running 'codex debug models --bundled' (fails when codex is not on the Tauri app's PATH, common in macOS GUI environments). This commit adds a three-tier fallback: 1. Try 'codex' from PATH, then platform-specific common paths (/opt/homebrew/bin/codex, /usr/local/bin/codex, etc.) 2. If all CLI attempts fail, use a compile-time embedded gpt-5.5 template (extracted from codex 0.135.0 bundled models) Also adds tests for the static template validity and CLI candidates. * fix(codex): discover user node codex installs --------- Co-authored-by: Jason <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
问题
当用户从未直连过 OpenAI(比如只用 DeepSeek 等第三方供应商)时,
~/.codex/models_cache.json永远不会被创建。cc-switch 在生成第三方供应商的模型目录时需要gpt-5.5模型定义作为模板,当前有两条获取路径:models_cache.json→ 不存在 ❌codex debug models --bundled→ 在 macOS GUI 环境下codex不在 Tauri 的 PATH 中,也找不到 ❌两条路都断了就会报:
相关 issue:#3325 #3337 #3343 #3378
修复
三层递进兜底,每层都是跨平台的:
第 2 层:
load_codex_model_template_from_bundled原来只试Command::new("codex"),现在遍历候选列表:第 3 层:新增
src-tauri/src/resources/gpt5_5_template.json,内容是codex debug models --bundled输出中gpt-5.5的完整条目(从当前 codex 0.135.0 提取),通过include_str!在编译时嵌入。无论用户环境如何,只要 cc-switch 能成功编译启动,就能拿到模板。测试
注意事项
静态模板需要在 Codex 更新其 agent 系统提示词(
model_messages/base_instructions)时同步更新。频率很低,过去一年未变。可以考虑在 CI 中加一个检查项或文档提示,提醒在升级 codex 依赖版本时检查模板是否过时。