Skip to content

对齐 CC Switch:统一推理意图、协议转换与路由策略优先级 - #541

Closed
guyu233 wants to merge 14 commits into
caigee-cmd:mainfrom
guyu233:pr4/ccswitch-alignment
Closed

guyu233 wants to merge 14 commits into
caigee-cmd:mainfrom
guyu233:pr4/ccswitch-alignment

Conversation

@guyu233

@guyu233 guyu233 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

CC Switch alignment work: unified reasoning intent parsing, protocol conversion, routing strategy precedence, and related follow-ups.

Adds logical models that aggregate real provider models behind one client-facing ID, with per-pool routing strategy, failover settings and weighted members. Keys can be restricted to aggregation grants. Adds a one-click per-account model availability probe that does not alter routing cooldowns or usage totals. Refreshes the console Models/Keys/navigation UI and embed assets. Adds a cross-region failover regression test and a project audit report. Ignores .dev-runtime/ which holds local auth blobs and runtime DBs.
@guyu233
guyu233 force-pushed the pr4/ccswitch-alignment branch from 949f23d to 1d85aef Compare November 19, 2026 03:26
@guyu233 guyu233 changed the title 对齐 CC Switch:统一推理意图、协议转换与路由策略优先级 fix(models): pass through client context windows Nov 19, 2026
@guyu233 guyu233 changed the title fix(models): pass through client context windows 对齐 CC Switch:统一推理意图、协议转换与路由策略优先级 Nov 19, 2026
@caigee-cmd

Copy link
Copy Markdown
Owner

感谢提交!这个 PR 里有几个很有价值的改动,特别是推理解析的统一和 usage 字段的归一化,方向都是对的。但目前有几个比较根本的问题,建议按下面的方式拆分重做:

阻断项

  1. 上下文窗口和 优化:强制最大上下文与目录能力展示 #539 行为相反
    本 PR 包含了 新增:跨供应商模型池与模型可用性检查 #538 和 优化:强制最大上下文与目录能力展示 #539 的早期提交,但漏掉了 优化:强制最大上下文与目录能力展示 #539 后面的关键撤回(a967394)。本 PR 自己的 5158632 改成了透传,但紧接着 64f0c95 Revert-context-window-fix 又把 ForceMaxContextLength 恢复了。最终结果是网关会无条件用 ForceMaxContextLength 覆盖 Qoder 请求的上下文,直接和 优化:强制最大上下文与目录能力展示 #539 冲突。这个问题需要先和 优化:强制最大上下文与目录能力展示 #539 的作者对齐,定下最终语义。

  2. ForceMaxContextLength 可能取到其他供应商的上下文窗口
    目前从合并后的 catalog(Peek("", CatalogModeMerge))取 catalog_context_length_max,这个值可能来自另一个供应商对同名模型的声明。如果另一个供应商声明了 1M 而 Qoder 实际限制更小,Qoder 请求就会带上超限的 max_input_tokens,直接报上下文超限错误。需要从账号自己的 catalog 条目取,或者不注入。

  3. Migration 编号冲突(和 新增:跨供应商模型池与模型可用性检查 #538 相同)
    main 已有 028_account_credit_floor.sql 和 029_account_percent_floor.sql,新的 aggregations migration 需要用 030。

  4. 非轮询策略下关掉了会话粘性,需要单独 PR
    sessionAffinityHonorsStrategy 让 fill-first、FEFO、按额度排序等策略都不保留 sticky 和 region latch。对于使用这些策略的账号,同一个对话会在账号之间跳,prompt cache 命中率会明显下降。这是路由契约的变化,影响面不小,建议单独开一个 PR,配上对照测试和 changelog。

关于 PR 体积

这个 PR 包含 116 个文件,同时覆盖了模型池、上下文窗口、额度路由、推理解析统一、协议转换和 usage 归一化,审查和回滚都很困难。建议拆成至少三个独立 PR:

  • PR A:额度路由策略(most-quota-first / least-quota-first)
  • PR B:会话粘性策略变化(非轮询下 sticky 失效)
  • PR C:推理解析统一 + usage 字段归一化

每个 PR 配上"旧输入对应旧输出"的对照测试,这样出问题了也好定位。

其他

  • docs/PROJECT_AUDIT.md 和 vite 端口改动(5179→5180)不应提交,请删掉(和 新增:跨供应商模型池与模型可用性检查 #538 同样的问题)
  • 推理解析统一(thinking_toggle.go,103 行)覆盖了 workbuddy、kimi、kiro、devin、command、zhipu、codearts、meta、codex、trae、qoder 等 11 个供应商,建议为每个供应商补一组"旧输入 → 旧输出"的对照测试,确认语义没有回退

整体方向是好的,拆开之后会更好审也更安全,期待更新 🙏

Rebuilt on current main. Migration is 031 (030 is reserved by the pending key aggregation PR). Display reasoning levels stay catalog-driven instead of merging the full gateway set, and local-only audit/vite changes are dropped. Changelog now notes probe quota cost and the priority-order default.
Chat requests no longer receive a gateway-chosen context window; only a client-supplied window is forwarded. Catalog maxima and Trae max mode are display/forward-only. The console per-model context setting and max-mode switches are dropped with a changelog note, and the changelog file now matches the passthrough semantics. Also aligns reasoning conversion with CC Switch (ultra tier, Anthropic thinking budgets).
@guyu233
guyu233 force-pushed the pr4/ccswitch-alignment branch from 64f0c95 to 449474a Compare November 23, 2026 08:18
@caigee-cmd

Copy link
Copy Markdown
Owner

感谢更新!上一轮提的问题里,这几项已经解决:

  • 上下文窗口已和 优化:强制最大上下文与目录能力展示 #539 对齐为「只透传客户端传入的值」,ForceMaxContextLength 已删除,不存在从合并 catalog 取到其他供应商窗口的问题
  • 迁移编号已改为 031_aggregations.sql
  • docs/PROJECT_AUDIT.md 和 vite 端口改动已移除
  • 推理解析统一补了 internal/providers/thinking_toggle_compat_test.go 和 thinking_toggle_test.go,usage 归一化补了 internal/gateway/anthropic_cache_test.go、responses_test.go 和 internal/translate/responses_events_test.go
  • 非轮询策略不再关闭会话粘性(sessionAffinityHonorsStrategy 已不在代码里),所以这项不需要再单独拆 PR

还不能合,有两个问题

  1. 和 新增:跨供应商模型池与模型可用性检查 #538 一样,卡在和 feat(keys): cross-provider model aggregation (stacked on #573) #574 的冲突。 本 PR 包含 新增:跨供应商模型池与模型可用性检查 #538/优化:强制最大上下文与目录能力展示 #539/修复与新增:路由策略及剩余额度优先策略 #540 的全部提交,而 新增:跨供应商模型池与模型可用性检查 #538 新增的 030_api_key_model_aggregation.sql 和已合并的 feat(keys): cross-provider model aggregation (stacked on #573) #574 撞车,且是两套不同的「模型聚合」实现(详见 新增:跨供应商模型池与模型可用性检查 #538 的评论)。需要等 新增:跨供应商模型池与模型可用性检查 #538 定稿后从下往上 rebase。

  2. PR 仍然同时包含四层改动,建议先不要在这个 PR 里继续堆。 现在 新增:跨供应商模型池与模型可用性检查 #538(模型池)、优化:强制最大上下文与目录能力展示 #539(上下文透传)、修复与新增:路由策略及剩余额度优先策略 #540(额度路由)都已各自成 PR,本 PR 独有的部分是推理解析统一、协议转换和 usage 归一化。等下面三层合并后,把本 PR rebase 成只含这部分的 diff,审查和回滚都会轻松很多。这部分本身我没有新的阻断意见。

@guyu233

guyu233 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor Author

CC Switch 专属改动已迁移到独立 PR #584;重叠的聚合/路由/缓存提交由 #581、#582、#583 承接。原分支为累积堆叠,关闭以清理重复 diff。

@guyu233 guyu233 closed this Nov 23, 2026
caigee-cmd added a commit that referenced this pull request Nov 23, 2026
feat: CC Switch 对齐(保留原 #541 的独立改动)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants