fix: remove public chat-to-responses auto conversion - #5364
Conversation
|
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 (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThis PR removes the automatic Chat Completions → Responses protocol conversion: the conversion endpoint now returns 400 Bad Request, the policy is hardcoded to false, alternate handler routing is removed, config is annotated as deprecated for backward-compatible storage, and frontend UIs/translations are updated to reflect the disabled legacy state. ChangesChat Completions → Responses Conversion Removal
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~45 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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@relay/chat_completions_via_responses_test.go`:
- Around line 15-18: The test TestChatCompletionsViaResponsesDisabled calls
gin.SetMode(gin.TestMode) which mutates global Gin state and is not restored;
capture the current mode before changing it (via gin.Mode()), set gin to
gin.TestMode for the test, and ensure you restore the previous mode at the end
of the test (use a defer to call gin.SetMode(prevMode)) so
TestChatCompletionsViaResponsesDisabled leaves global Gin state unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6f7cf43c-1272-4172-8b6b-b0e7fe820367
📒 Files selected for processing (15)
relay/chat_completions_via_responses.gorelay/chat_completions_via_responses_test.gorelay/claude_handler.gorelay/compatible_handler.goservice/openaicompat/policy.goservice/openaicompat/policy_test.gosetting/model_setting/global.goweb/classic/src/pages/Setting/Model/SettingGlobalModel.jsxweb/default/src/features/system-settings/models/global-settings-card.tsxweb/default/src/i18n/locales/en.jsonweb/default/src/i18n/locales/fr.jsonweb/default/src/i18n/locales/ja.jsonweb/default/src/i18n/locales/ru.jsonweb/default/src/i18n/locales/vi.jsonweb/default/src/i18n/locales/zh.json
💤 Files with no reviewable changes (2)
- relay/claude_handler.go
- relay/compatible_handler.go
Summary
This PR removes the public Chat/Claude endpoint auto-conversion path that silently rewrote chat-completions requests into Responses requests and then wrapped the Responses stream back into Chat Completions chunks.
The public endpoint should preserve its protocol semantics:
/v1/chat/completionsand Claude-compatible public entries should stay on their native relay path./v1/responsesshould stay on the native Responses relay path.chat -> responses -> chatconversion should not alter the stream protocol visible to clients.Root Cause
The issue was not the native
/v1/responsesroute. The native Responses route emits Responses stream events correctly.The problematic chain was:
/v1/chat/completionsor Claude-compatible entryglobal.chat_completions_to_responses_policymatched/v1/responseschat.completion.chunkobjects from the hidden compatibility layerThat means the public API endpoint semantics could be pierced by a hidden compatibility setting.
What Changed
chatCompletionsViaResponsesfrom the OpenAI-compatible and Claude-compatible relay handlers.Note for Maintainers
这确实是服务端逻辑错误,不是客户端“挑剔”。
/v1/responses原生链路本身没错。真正的问题就是公开 chat/Claude 入口被隐藏逻辑偷偷改成 responses,再包装回 chat,导致协议语义被打穿。
现在这条自动转换链已经从根上停掉了。
hurry那个completion_tokens=0/ 空输出问题我没有碰,仍然应该单独分析。Validation
go test ./service/openaicompat ./relaySummary by CodeRabbit
Breaking Changes
Tests
UI Updates
Localization