fix(convert): forward Claude output_config.effort as reasoning_effort to OpenAI-format upstreams - #5993
Conversation
… to OpenAI-format upstreams When a Claude-format request carrying output_config.effort (e.g. reasoning effort high from Claude clients) is converted for a non-OpenRouter OpenAI-format channel, the effort value was silently dropped: ClaudeToOpenAIRequest only consumed GetEfforts() in the OpenRouter branch, so the upstream request never contained reasoning_effort. Populate GeneralOpenAIRequest.ReasoningEffort in the generic branch. The OpenAI channel adaptor already handles this field downstream (o-series/gpt-5 suffix handling, OpenRouter reasoning mapping), so no adaptor changes are needed. OpenRouter conversion behavior is unchanged. Closes QuantumNous#5922
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughClaudeToOpenAIRequest now maps non-empty Claude effort values to ReasoningEffort for non-OpenRouter channels, fixing a gap where this mapping previously only applied to OpenRouter via Verbosity. Three new tests validate forwarding, absence handling, and unchanged OpenRouter behavior. ChangesEffort Mapping Fix and Tests
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning Tools execution failed with the following error: Failed to run tools: 13 INTERNAL: Received RST_STREAM with code 2 (Internal server error) Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
51fdfc5 to
2b6f1df
Compare
Important
📝 变更描述 / Description
修复 #5922:Claude 格式客户端设置 reasoning effort(请求体中的
output_config.effort,如high)后,经 OpenAI 类型渠道转发时该参数被静默丢弃,上游收不到reasoning_effort。根因:
service/convert.go的ClaudeToOpenAIRequest中,claudeRequest.GetEfforts()(解析output_config.effort)只在 OpenRouter 分支被消费;非 OpenRouter 的通用分支(即 OpenAI 类型渠道走的路径)完全没有读取 effort,转换后的GeneralOpenAIRequest.ReasoningEffort恒为空。修复:在通用分支中把 effort 赋给
openAIRequest.ReasoningEffort(一行改动)。之所以只需要改这一处:OpenAI 渠道 adaptor 的ConvertClaudeRequest会把转换结果继续送入ConvertOpenAIRequest(relay/channel/openai/adaptor.go),后者对request.ReasoningEffort已有完整的下游处理链(o 系列 / gpt-5 的模型后缀与参数适配、OpenRouter 的reasoningJSON 映射、info.ReasoningEffort日志记录),本次填上字段后即可复用全部既有逻辑。OpenRouter 分支的 effort 映射行为保持不变。🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
新增回归测试
service/convert_effort_test.go(testify,三个场景):output_config: {"effort": "high"}→ 转换结果含"reasoning_effort":"high"(对应 issue 复现场景)。output_config→reasoning_effort不出现(omitempty,不污染无推理需求的请求)。reasoning_effort字段。全量回归:
go test ./service/... ./relay/...全部通过,go vet ./service/无告警。Summary by CodeRabbit
Bug Fixes
Tests