Repository navigation
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved issues allow unsupported aliases and sampling fields, cause token-counting failures, and can forward mapped reasoning that violates policy ceilings or GLM’s native scale.
5 open issues
Allow disabled-thinking token counts with mapped none effort · New Normalize mapped reasoning effort for GLM models · New Clear unsupported sampling fields for mapped gpt-6.1-sol requests · New Normalize model aliases before checking minimal-effort suffix · New Preserve effort ceilings for disabled-thinking none mappings · New
What changed in this PR
This PR addresses #8156 by applying configured mappings to synthesized none reasoning effort in the Messages bridge, while preserving ordinary defaults and validation of unsupported explicit values.
Changes:
- Bind
nonemappings when clients omitoutput_config.effort. - Validate final effort after policy application in Responses and Chat Completions forwarding.
- Add regression coverage for disabled thinking, defaults, mappings, and rejection behavior.
| File | Description |
|---|---|
backend/internal/service/openai_reasoning_effort_policy.go |
Adds Messages-specific policy binding. |
backend/internal/service/openai_messages_effort_policy_test.go |
Tests forwarding and effort-policy behavior. |
backend/internal/service/openai_gateway_request_body.go |
Separates raw-effort validation from compatibility checks. |
backend/internal/service/openai_gateway_messages.go |
Defers synthesized-effort validation until after mapping. |
backend/internal/service/openai_gateway_messages_chat_fallback.go |
Validates final Chat Completions effort after mapping. |
backend/internal/service/apicompat_config.go |
Removes the replaced conversion wrapper. |
backend/internal/pkg/apicompat/anthropic_to_responses.go |
Adds optional deferred effort validation. |
backend/internal/pkg/apicompat/anthropic_effort_validation_test.go |
Tests strict and deferred conversion validation. |
backend/internal/handler/messages_effort_policy_test.go |
Tests policy binding across supported platforms. |
backend/internal/handler/composite_platform.go |
Uses Messages-specific policy binding. |
backend/internal/handler/composite_platform_test.go |
Covers synthesized defaults and disabled thinking. |
Review effort: Balanced
| responsesReq, err := apicompat.AnthropicToResponsesWithOptions(&anthropicReq, apicompat.AnthropicToResponsesOptions{ | ||
| MinOutputTokens: configuredMinOutputTokens(s.cfg), | ||
| DeferReasoningEffortValidation: true, | ||
| }) |
There was a problem hiding this comment.
已在当前 head f6ea845 保留 count_tokens 延迟 effort 校验,新增 disabled thinking/none 映射计数回归;完整本地检查及远端 CI 通过。
| chatBody = policyBody | ||
| } | ||
| } | ||
| if err := validateGPT61SolCompatRequest(chatBody, upstreamModel); err != nil { |
There was a problem hiding this comment.
按维护者最新明确意见,f6ea845c58266af39bcaef3181d9b8f9692d2772 保持 main 的 GLM 归一化→分组映射/上限顺序,移除改变 downgrade 语义的额外 GLM helper;不在此 PR 新增原生档位限制。medium 出站与计费、显式 downgrade/deny 的流式和非流式边界已验证。
| if err := validateGPT61SolCompatRequest(chatBody, upstreamModel); err != nil { | ||
| writeAnthropicError(c, http.StatusBadRequest, "invalid_request_error", err.Error()) | ||
| return nil, err | ||
| } |
There was a problem hiding this comment.
当前 head f6ea845 在解析目标 gpt-6.1-sol 后移除 temperature/top_p,再校验最终 effort;转发边界回归与完整本地/远端 CI 通过。
| return nil | ||
| } | ||
|
|
||
| func validateGPT61SolRawEffort(body []byte, model string) error { |
There was a problem hiding this comment.
当前 head f6ea845 对模型规范化后检查 minimal 后缀,保留显式不支持值的拒绝;Responses/Chat 边界测试及完整本地/远端 CI 通过。
| // client omits output_config.effort, binding only mappings for synthesized none. | ||
| func WithOpenAIReasoningEffortPolicyForMessages(ctx context.Context, body []byte, maxEffort string, mappings []ReasoningEffortMapping, overLimit string) context.Context { | ||
| if strings.TrimSpace(gjson.GetBytes(body, "output_config.effort").String()) == "" { | ||
| maxEffort = "" |
There was a problem hiding this comment.
当前 head f6ea845 对 disabled thinking 保留上限,映射后继续 downgrade/deny;普通省略 effort 不限制默认档。对应边界回归及完整本地/远端 CI 通过。
|
感谢更新。上轮提到的两点已确认修复:省略 effort 时不再触发 deny 上限 403;gpt-6.1-sol 的兼容校验已移到策略之后。剩余以下问题: 1. 省略 effort + thinking disabled 时可绕过分组上限
建议:省略 effort 且 2. 与 #8309 冲突,需 rebase本 PR 落后 main 约 90 个提交(单独合入 main 无冲突),但与 #8309 在
3. 小问题
另:#5602 与本 PR 语义相反(禁止 none 作为映射源),且基于旧签名,已无法应用到 main;main 在 7969751 已支持 none 映射源,不影响本 PR。 |
|
感谢更新。上轮三点已确认修复:省略 effort 且 剩余一个阻塞问题: 1. GLM 路径把
|

背景
改动
验证
Fixes #8156