Skip to content

fix: 提示缓存命中率与会话亲和 - #583

Merged
caigee-cmd merged 11 commits into
caigee-cmd:mainfrom
guyu233:fix/prompt-cache-affinity
Nov 23, 2026
Merged

caigee-cmd merged 11 commits into
caigee-cmd:mainfrom
guyu233:fix/prompt-cache-affinity

Conversation

@guyu233

@guyu233 guyu233 commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

本 PR

修复缓存命中率低的网关侧原因,目标是健康会话稳定落到同一账号/模型,失败后只付一次冷启动:

  • 聚合逻辑模型保留 session affinity:绑定账号按 plan 成员校验,不再每轮重置成通用 routingPool。
  • 流式请求在上游接受响应头/首个成功事件时立即绑定,不再等整个流结束;第一轮流未结束时,下一轮也能复用同一账号。
  • 非流式、流式、native responses 全部按 pool account ID 做 session binding、cooldown、failover;worker 回写的 X-Qoder-Account 标签不会覆盖 pool 绑定。
  • failover 时失效 session binding,包括 sticky-escape 场景,避免下一轮先重试已失败账号。
  • canonicalize 各 provider 的 cache read/write token 字段,缓存统计口径统一。

依赖

堆叠在 #581(聚合基线) 和 #582(账号路由 failover) 之上;请按顺序合并。

上线门槛

必须所有 required checks 通过后才能合并和上线;任何检查失败都不得上线。

需要全部通过:go、windows-host、worker、frontend、container、secrets。

本地验证

  • go build ./... 通过
  • 聚合 sticky、failover 重绑、流式提前绑定、worker 标签回写绑定、cache token 定向测试通过
  • go test ./internal/gateway 通过

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.
Add account_id to aggregation members end to end: schema migration, store, console API, model pool editor, and matching. Legacy members without account_id keep provider-wide pool behavior.
Expose least-quota-first and most-quota-first for model pools and global routing, with normalized strategy loading and candidate counting aligned to the selected strategy.
@guyu233
guyu233 force-pushed the fix/prompt-cache-affinity branch from 8262fa6 to c136d10 Compare November 23, 2026 10:37
@guyu233
guyu233 force-pushed the fix/prompt-cache-affinity branch from c136d10 to 7bc110c Compare November 23, 2026 10:46
…ation

Release the implicit region latch only on cross-provider routes, preserve the retry budget after the first pick, give each priority tier its own budget, and apply account aliases in the worker path. Provider-scoped Qoder routes keep their region isolation.
Keep aggregate sessions bound to a member, bind streams at the first accepted event, use pool account IDs for binding/cooldown/failover, invalidate stale bindings on failover, and canonicalize provider cache token fields.
@guyu233
guyu233 force-pushed the fix/prompt-cache-affinity branch from 7bc110c to 8d649ba Compare November 23, 2026 10:53
@caigee-cmd
caigee-cmd merged commit 7e07545 into caigee-cmd:main Nov 23, 2026
6 checks passed
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