fix: route Codex Claude/chat requests through responses conversion - #4285
fix: route Codex Claude/chat requests through responses conversion#4285fanruan-tuco wants to merge 2 commits into
Conversation
Codex only supports the responses API, so force Claude messages and chat completions requests onto the existing responses conversion path instead of hitting unsupported adaptor endpoints. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
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)
WalkthroughThe PR modifies request routing logic in Claude and compatible handlers to unconditionally route Codex channel requests through the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
|
不考虑对Codex渠道做除了本身就支持的行为的适配处理 |
我们确实很需要这个功能! 这个pr经过本地验证可以使用,需要的话自行patch |
请问用在claude code中使用可以支持缓存吗 |
Important
📝 变更描述 / Description
本次修改让 Codex (OpenAI OAuth) 渠道能够正确处理 Claude /v1/messages 和 OpenAI Chat /v1/chat/completions 请求。
在此之前,Codex 渠道本身只实现了 Responses API 路径,请求如果落到 ConvertClaudeRequest 或 ConvertOpenAIRequest 会直接返回 endpoint not supported。
但项目内部已经存在完整的转换链:
问题不在于缺少转换能力,而在于这条转换链原本只会在策略条件命中时启用。对于 Codex 渠道来说,这不应该是可选策略,而应该是固定路径,因为它本身只支持 Responses API。
因此这次改动在两个 handler 中增加了 Codex 渠道判断:
当渠道类型为 Codex 时,直接进入现有的 chatCompletionsViaResponses 路径,而不是继续走 Codex adaptor 中未实现的 Claude / Chat 原生转换入口。这样可以复用项目已有的协议转换逻辑,并确保最终请求以 Responses 格式发送给 Codex 上游。
实际效果:
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
Summary by CodeRabbit