refactor(responses): remove compact model suffix handling - #6770
Conversation
WalkthroughThe PR makes Responses Compact support channel-aware and removes automatic compact model suffix generation. Endpoint handling, Codex model discovery, model mapping, and ratio lookups now use standard model names. ChangesResponses Compact behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 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 `@common/api_type.go`:
- Line 91: Update SupportsResponsesCompact in common/api_type.go (line 91) to
return true only for explicitly supported channelType/apiType pairs, using both
parameters in the gate. Add mismatched channel/API cases expecting false in
controller/channel_test_internal_test.go (lines 105-111), while retaining the
existing valid positive cases.
🪄 Autofix
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 Plus
Run ID: f733d5f3-0407-498b-b02b-6d0e28133918
📒 Files selected for processing (10)
common/api_type.gocontroller/channel-test.gocontroller/channel_test_internal_test.gomiddleware/distributor.gorelay/channel/codex/constants.gorelay/helper/model_mapped.gorelay/responses_handler.goservice/codex_channel_models.gosetting/ratio_setting/compact_suffix.gosetting/ratio_setting/model_ratio.go
💤 Files with no reviewable changes (3)
- middleware/distributor.go
- setting/ratio_setting/model_ratio.go
- setting/ratio_setting/compact_suffix.go
| } | ||
|
|
||
| func IsResponsesCompactAPIType(apiType int) bool { | ||
| func SupportsResponsesCompact(channelType, apiType int) bool { |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Enforce the channel/API pair in SupportsResponsesCompact.
channelType is unused. Any supported apiType returns true, including unsupported channel/API combinations. This makes the channel-aware compact gate ineffective.
common/api_type.go#L91-L91: returntrueonly for each supported channel/API pair.controller/channel_test_internal_test.go#L105-L111: add mismatched channel/API cases that expectfalse. The current positive cases also pass with API-type-only logic.
📍 Affects 2 files
common/api_type.go#L91-L91(this comment)controller/channel_test_internal_test.go#L105-L111
🤖 Prompt for 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.
In `@common/api_type.go` at line 91, Update SupportsResponsesCompact in
common/api_type.go (line 91) to return true only for explicitly supported
channelType/apiType pairs, using both parameters in the gate. Add mismatched
channel/API cases expecting false in controller/channel_test_internal_test.go
(lines 105-111), while retaining the existing valid positive cases.
Merge upstream main (13 commits incl. QuantumNous#6770 compact-suffix removal, codex model discovery, billingexpr updates) into feat. Conflict resolutions: - i18n: union of both sides' keys across all 7 locale files (pure additions) - relay/channel/{deepseek,openai,xai}: keep ReasoningEffortFromChannel guards, adopt main's nil-safe SetReasoningEffort - relay/claude_handler.go: keep feat prepareClaudeRequest + main effort recording - relay/helper/price.go: drop CompactModelSuffix dead references (QuantumNous#6770) - web models-table / channel-selector-dialog / upstream-ratio-sync-table: keep feat rewrites, adopt main search debounce - drop feat price_test.go compact-suffix subtest (feature removed in QuantumNous#6770)
…pact suffix refs Merge origin/main into feat/error-message-override. Resolved conflicts in 5 files by keeping both feature additions (error override settings and the channel failover / model alias settings) side by side: - model/option.go (ErrorOverrideEnabled + ChannelFailoverEnabled cases) - system-behavior-section.tsx (both FormField blocks) - operations/index.tsx, section-registry.tsx, types.ts (both fields) While validating the merge, found that main's refactor bb234ff (QuantumNous#6770) removed ratio_setting.CompactModelSuffix / WithCompactModelSuffix but the failover/alias code merged in #8 still referenced them: - setting/model_setting/model_alias.go: ResolveModelAlias stripped and re-added the compact suffix around alias resolution. Now resolves the requested name verbatim, matching QuantumNous#6770's removal of compact-suffix special-casing. Updated the compact test case to assert verbatim aliasing of a compact-suffixed name instead. - middleware/distributor.go: dropped the strings.TrimSuffix(resolvedModel, ratio_setting.CompactModelSuffix) call so the rewritten request body model matches the resolved alias exactly. Also fixed two pre-existing build/vet breakages from the #8 merge that surfaced once compact-suffix references compiled: - controller/relay.go: shouldRetryTaskRelay gained a failoverEnabled bool parameter on the call site (line 637) but the definition was not updated; added the parameter to the signature and removed the stale reference to the unqualified failoverEnabled identifier. - model/channel_cache_failover_test.go: imported AdvancedCustomConfig from the root dto package, but it lives in relaykit/dto; switched the import alias accordingly. Verified: go build ./... + go vet ./... pass, relaykit builds standalone (GOWORK=off), and ./setting/operation_setting, ./service, ./model, ./setting/model_setting, relaykit/types tests all pass.
Important
📝 变更描述 / Description
(简述:做了什么?为什么这样改能生效?请基于你对代码逻辑的理解来写,避免粘贴未经整理的内容)
移除之前由于很多供应商不支持/v1/responses/compact而为模型列表加入的特殊模型名兼容逻辑。
本PR合并后,/v1/responses/compact将直接转发给 openai/azure/newapi/sub2api/codex 上游,计费按照请求模型计费,与/v1/responses一致,之前的 openai-compact模型后缀模型成为无效模型名,不会在内部进行处理。
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
✅ 提交前检查项 / Checklist
Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。📸 运行证明 / Proof of Work
(请在此粘贴截图、关键日志或测试报告,以证明变更生效)
Summary by CodeRabbit
New Features
Changes