perf: harden gateway, billing, and ops paths under high concurrency - #4337
perf: harden gateway, billing, and ops paths under high concurrency#4337DR-lin-eng wants to merge 280 commits into
Conversation
|
Thank you for your contribution! Before we can merge this PR, we need you all to sign our Contributor License Agreement (CLA). To sign, please reply with the following comment:
You only need to sign once — it will be valid for all your future contributions to this project. I have read the CLA Document and I hereby sign the CLA 14 out of 15 committers have signed the CLA. |
I have read the CLA Document and I hereby sign the CLA |
recheck |
recheck |
|
recheck |
|
I have read the CLA Document and I hereby sign the CLA |
|
recheck |
604fb67 to
dfa806f
Compare
…index drift Close open text parts before late reasoning/tool items, and only stop matching Anthropic content-block types so finalize cannot close tool_use with a spurious output_text.done. Co-authored-by: Cursor <cursoragent@cursor.com>
Opus 4.8/4.7、Sonnet 5、Fable 5 上 thinking.display 默认为 "omitted": 模型照常思考、照常计费,但返回的 thinking block 文本为空,客户端无从 展示,终端用户会误以为上游不支持思考。 新增系统级三态开关 RectifierSettings.ThinkingDisplayMode: - display_only(默认):只为已带 thinking.type=adaptive 的请求补 display=summarized。思考本来就在发生并计费,补齐不增加任何 token, 也不影响 messages 层 prompt 缓存。 - force:额外为完全未携带 thinking 的请求注入思考。这会真正开启思考, 故同时抬高 max_tokens——max_tokens 是思考+正文的总上限,在低预算请求 上强开思考会让正文被截断且上游不报错。 - off:完全不干预。 顺带修复:客户端发 thinking.type="enabled" / budget_tokens 给这些模型 必定 400,而既有的 RectifyThinkingBudget 400 重试救不了它——它只调整 budget_tokens 的取值,而这些模型是整个拒绝该字段,重试照样 400。现归一 化为 adaptive。 注入点有两处:主转发链路与 Anthropic API-key 直通链路(后者在 gateway_forward.go 提前 return,不经过整流链)。只做一处会让同一用户因 调度到的账号不同而时有时无,比一直没有更像故障。 GetThinkingDisplayMode 带 nil 接收者守卫:GetRectifierSettings 直接 解引用 settingRepo,而本方法在网关热路径上调用。
Summary
Key changes
Testing
go test ./...golangci-lint v2.9.0 run --timeout=30m ./...make test-frontendpnpm --dir frontend run buildI have read the CLA Document and I hereby sign the CLA