[Bug][Codex V2] 保存 V2 子 Agent 后回读校验失败:写入与回读使用不同模型目录/Provider 上下文
环境
- CCSwitchMulti:
v3.19.2-16.2 - macOS
- 当前 Codex Provider:
codex-multirouter-company(MultiRouter Pro 公司) - 目标供应商:Bitto
- 涉及功能:Codex Sub-Agent V2 保存流程
症状
在 V2 子 Agent 页面点击“保存 V2 子 Agent 配置”后,前端提示:
Codex Agent 文件写入后回读校验失败。
数据库保存看起来已经发生,但 Agent 文件投影与回读校验不一致。
我定位到的根因
-
写入阶段和回读阶段使用了不同的 Provider 上下文。
finish_codex_subagent_v2_mutation调用codex_subagent_v2_write_verification,验证时通过codex_provider_classification_context传入ProviderClassificationContext。- 但
publish_codex_multirouter_projection仍调用prepare_codex_config_text_with_model_catalog_without_provider_context,即写入 Agent 文件时没有传入 Provider 上下文。 - 对于
mode=all路由,或模型没有命中 rawmatchPrefixes的情况(例如glm-5.3、deepseek-v4-flash-vision),写入阶段可能把模型判为不可路由、不生成角色文件;回读校验阶段却根据 target provider 目录判为可路由、要求文件存在,于是返回失败。
-
投影后的 modelCatalog 没有写回数据库,V2 编译仍只读数据库里的原始 modelCatalog。
- 前端
saveSpawnAgentCandidates/handleSaveRoutingRoutes保存时不会把selectedProjectedCatalog写回 Provider 的settingsConfig.modelCatalog。 codex_catalog_model_specs仍从settings.modelCatalog读取,而投影后的聚合 catalog 只写到 Live 文件。- 因此 Bitto 新增的
deepseek-v4-flash-vision已出现在~/.codex/cc-switch-model-catalog.json和 UI 投影中,但不会自动出现在当前 MultiRouter 的 V2 后端模型列表里。
- 前端
本机证据(手动修复前)
- Bitto Provider 的
modelCatalog有:deepseek-v4-flash-vision
- 当前 MultiRouter 的
settingsConfig.modelCatalog之前没有deepseek-v4-flash-vision - 当前 MultiRouter 的
codexRouting.subagentV2.profiles之前没有deepseek-v4-flash-vision - 实际生成的 Live catalog 有
deepseek-v4-flash-vision ~/.codex/agents缺少glm-5-3.toml,因为 Bitto 路由matchPrefixes没有glm- 手动把模型名规范化为
deepseek-v4-flash-bitto、并给 Bitto 路由补上glm后,glm-5-3.toml、deepseek-v4-flash-bitto.toml、gpt-5-6-luna.toml、gpt-5-6-sol.toml均能生成且内容与预期一致
关联问题 / PR
- 与 #28 的“modelCatalog 被删/投影不回写 DB”高度相关
- 与 #29 的“V2 matchPrefixes 未被识别 / mode=all 分类不一致”高度相关
- 与 #48 的 alias/vision 变体误判相关
- PR #35、PR #49 以及 commit
1c2e4cae解决了其中一部分,但我在 PR #35 head 上仍看到publish_codex_multirouter_projection使用without_provider_context,且saveSpawnAgentCandidates仍未把投影 modelCatalog 写回 DB
建议修复方向
- 让 Agent 文件写入和回读校验使用同一份 Provider 上下文;例如
publish_codex_multirouter_projection也接收ProviderClassificationContext,或统一由投影设置编译。 - 保存 MultiRouter 路由/子 Agent 候选后,把投影生成的
modelCatalog写回 Provider DB 的settingsConfig.modelCatalog;或让codex_catalog_model_specs从codex_multirouter::projection生成模型列表。 - 补回归测试:
mode=all且matchPrefixes为空/未命中时,写入与验证一致;- 目标供应商新增加模型后,刷新/保存 V2 列表能自动加入;
- 保存 V2 后
verification.role_files_status == verified。
如果需要,我可以提供本机修复前后的数据库备份路径和日志证据。
跟进:母仓库 main 的 v3.19.2-17 已包含等价修复(effective_settings_for_candidate、codex_subagent_effective_settings、provider-driven subagent sync 等)。此前基于旧分支提交的 PR #66 已标注 superseded 并关闭;fork 分支 fix/65-subagent-readback 仍保留本次补丁,供需要做旧版本 backport 时使用。
此 issue 已超过 60 天没有活动,已被标记为 stale。
如果此问题仍然存在,请回复以保持 issue 打开状态,否则将在 14 天后自动关闭。
This issue has been automatically marked as stale because it has not had activity for 60 days.
Please reply to keep it open, otherwise it will be automatically closed in 14 days.
此 issue 因长时间无活动已被自动关闭。如果问题仍然存在,欢迎重新打开。
This issue has been automatically closed due to inactivity. If the problem persists, feel free to reopen it.