fix(relay-switch): 切换前回填不再采纳 cc-switch 写入的外部供应商配置 (issue #1497 #783 #975) - #2388
Open
leiming2333 wants to merge 1 commit into
Open
leiming2333 wants to merge 1 commit into
leiming2333 wants to merge 1 commit into
Conversation
BigPizzaV3#783 BigPizzaV3#975) cc-switch 与 Codex++ 的默认模板占用同一个 provider id(custom)。 cc-switch 接管 ~/.codex 后,live config.toml 变成另一套供应商的投影, 此时用户回 Codex++ 切换供应商,backfill 会把外部供应商的 base_url / API Key 身份 / 模型 / cc-switch catalog 指针整段固化进上一个 Codex++ 供应商;用户切回该供应商时上游、密钥、模型全部错乱,表现为切不回模型。 判定条件(三条同时满足才跳过回填,手工编辑不受影响): - live 与模板的活跃 provider id 相同; - 双方 base_url 均非空且不相等; - live auth.json 的 OPENAI_API_KEY 与模板 API Key 均非空且不相等。 协议代理/聚合模式写 live 时复用 profile 自己的 Key,仅改 base_url 或 仅换 Key 的手工编辑、以及换了 provider id 的形态均不满足全部条件, 仍走原有回填路径。
This branch has not been deployed
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.
问题
cc-switch 与 Codex++ 存在配置接管冲突(#1497 #783 #975):
model_provider = "custom")。~/.codex/config.toml变成 cc-switch 供应商的投影(不同的 base_url / API Key / 模型,以及model_catalog_json = "cc-switch-model-catalog.json"指针)。backfill_relay_profile_from_home_with_common)会把 live 整段采纳进"上一个 Codex++ 供应商"(restore_profile_provider_id_for_backfill只在 provider id 不同时改名保护,同名时不设防)。修复
在切换前回填入口新增守卫
live_config_is_foreign_provider:三条条件同时满足才判定 live 已被外部管理器写成另一套供应商,跳过整段回填(保持模板原样,交给本次切换直接覆盖 live):custom的根源);不影响既有契约:
manual_a形态:改 provider id + base_url + Key)不满足条件 1,仍完整回填,switch_backfills_previous_profile_from_live_before_selecting_target保持通过;测试
switch_does_not_backfill_foreign_provider_written_by_cc_switch:复现"cc-switch 接管 → Codex++ 切换供应商 → 上一个供应商被污染"的完整链路。修复前失败(供应商 a 被写入 cc-switch 的 base_url、模型与 catalog 指针),修复后通过。cargo test -p codex-plus-core:909 通过。唯一失败的app_paths_resolves_portable_current_link_to_directory_version在未修改的main上同样失败(本机 GNU 工具链环境相关,与本次改动无关)。Closes #1497
Closes #783
Refs #975