Repository navigation
fix(gateway): enforce effort policies on Anthropic compatibility routes - #8739
Merged
Wei-Shaw merged 1 commit intoNov 16, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #8713
Anthropic 分组通过
/v1/chat/completions或/v1/responses转发时,会跳过分组的推理强度映射与上限。例如分组上限为medium,请求high仍会以output_config.effort: "high"发给 Anthropic;配置为拒绝超限请求时也会继续转发。两个入口现在复用现有策略 helper,在调度和计费预留前应用映射、上限和拒绝规则,并沿用各自现有错误格式。原始请求强度与最终生效强度分别保留在用量记录中。
回归通过真实
GatewayHandler、协议转换、内存上游及用量仓储执行,覆盖两个入口、流式/非流式、Anthropic/Composite 分组、映射与模型匹配、映射后封顶、拒绝、无限制与缺省值。最终同一组 80 个场景在未修改的main@530c5e3a4为 48 失败/32 对照通过;修复后 80 全部通过。验证:
golangci-lint v2.14.0全后端检查:0 issues;gofmt与git diff --check通过。附加带
unit标记的 handler lint 在基线对照与修复代码中均报告auth_wechat_oauth_test.go/user_platform_quotas_handler_test.go的 8 项既有问题;增量 lint 为0 issues。原始失败结果已保留。当前上游的 Go 1.27.3 安全基线升级由 #8670 单独处理,本分支未混入该工具链补丁。使用合成 HTTP/SSE 响应和临时测试数据库,未调用真实 Anthropic 或验收生产部署。实现与验证由 AI agent 完成。