MultiRouter 模型匹配语义缺陷:include 反选被前缀放行 / 无匹配 fallback 官方 / mode=all 无前缀路由模型误判不可路由
背景
MultiRouter 模型选择的语义与运行时路由不一致,共三个相互关联的缺陷(v3.19.2-16 实测)。前两个与本仓库 #29 相关但属于补充语义;第三个是取消 fallback 后暴露的既有缺陷。
问题
1. include 反选被前缀匹配放行
官方 route 是 include 模式(精确白名单 ["gpt-5.6-sol","gpt-5.6-terra","gpt-5.6-luna"]),但向导生成的 matchPrefixes=["gpt","o"] 使前缀匹配独立于 include("或"关系而非"与"关系)。被反选的 gpt-5.4/5.5 仍可通过 startsWith("gpt") 命中官方 route:
- 前端
routeCanMatchVisibleCatalogModel、后端codex_route_matches_model、codex_catalog_route_matches_model、databaseroute_matches_model四处exact OR prefix同一缺陷; - 表现:排序界面/子 agent 界面仍能选到反选模型,运行时仍路由到官方。
2. 无匹配模型 fallback 到默认路由(官方)
未勾选源(如 Qwen/Bitto)没有 route,其模型(qwen3.8/glm-5.3)在 exact/prefix 均不匹配后 fallback 到 defaultRouteId/第一条 enabled route(官方):
- 真实请求打到 OpenAI 官方(404);
- 子 agent 分组误判"官方"。
- 代码注释自述为 historical behavior,但语义上"反选/未勾选 = 明确排除"与之冲突。
3. mode=all 且 matchPrefixes 为空的路由,其模型误判不可路由
Kimi route 为 mode=all 且 matchPrefixes=[](向导 inferWizardRoutePrefixes 不识别 "Kimi",未生成前缀)。raw settings 匹配(exact OR prefix)无法命中 k3/k3-256k:
- 修复 #2 取消 fallback 后,k3 从"错误归官方"变为"unroutable";
- 子 agent 角色编辑器里 k3/k3-256k 角色消失;
- 编译层
collect_candidates的CodexModelSelection::All => None本就正确收集 target 全部模型,raw settings 分类层缺这一语义(两层不一致)。
建议修复
- include 模式下前缀匹配必须同时命中 include 列表("与"语义,统一 4 处);
- 无匹配模型一律 fail-closed(不可路由),不 fallback 默认路由;
- mode=all 路由按 target provider catalog 匹配其全部模型(与编译层对齐)。
对应 PR:#(待 PR 创建后回填)
PR #35 已创建:https://github.com/BigStrongSun/ccswitchmulti/pull/35(含 fork 分支 14 个 commit 的全部修复)
补充第 4 个缺陷(已修复,commit a898b58f):
前端投影丢失模型推理能力(reasoning):catalogDraftFromSourceModel 重建 catalog draft 时未复制 reasoning 字段,导致工作台模型能力界面显示模型无档位(如 gpt-5.6-luna 的 max 档位消失),而后端 compile 层生成的 config.toml 含 max——两层不一致。已修复并补回归测试。
PR #35 已更新为 15 个 commit(前端 1167 passed,tsc 零错误)。
此 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.