Skip to content

feat: make channel test follow global OpenAI completions via responses rules#4888

Open
layou233 wants to merge 1 commit into
QuantumNous:mainfrom
layou233:channel-test-responses-rule
Open

feat: make channel test follow global OpenAI completions via responses rules#4888
layou233 wants to merge 1 commit into
QuantumNous:mainfrom
layou233:channel-test-responses-rule

Conversation

@layou233

@layou233 layou233 commented May 15, 2026

Copy link
Copy Markdown

⚠️ 提交说明 / PR Notice

当前渠道测试代码里,自动检测部分对 Codex 模型自动使用 Responses API,但是仍有其他模型(并且未来可能会有更多)仍只通过 Responses API 提供,如 gpt-5.4-pro。

为了使其与系统其他部分更加直观统一,可以在自动检测逻辑中应用全局设置里的 Chat Completions API -> Responses API 转换规则,按规则直接改为使用 Responses API。

另:我们是否需要给 gpt-pro 系列也如同 codex 系列一样,硬编码使用 Responses API?

📝 变更描述 / Description

  1. 将自动检测逻辑从多个 if 转为 if-else 链,以进行优先级覆盖
  2. 满足 ShouldChatCompletionsUseResponsesGlobal 时将端点设置为 Responses API。
  3. 简化注释并改为英文注释。

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • ✨ 新功能 (New feature) - 重大特性建议先通过 Issue 沟通
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 IssuesPRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

(请在此粘贴截图、关键日志或测试报告,以证明变更生效)

Summary by CodeRabbit

  • Refactor
    • Streamlined endpoint auto-detection with a prioritized conditional chain, improving selection among rerank, embeddings, image generation, and response endpoints; refined fallback behavior for global response switching to apply only when earlier checks don't match.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 15, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0ad66cc5-2422-4eb0-ad7d-50b48d496c3a

📥 Commits

Reviewing files that changed from the base of the PR and between 1808840 and 9ca25e1.

📒 Files selected for processing (1)
  • controller/channel-test.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • controller/channel-test.go

Walkthrough

The testChannel function's endpoint auto-detection logic was refactored from multiple independent if statements into a prioritized if/else-if chain, changing precedence. A global settings check was added to route to /v1/responses as a fallback.

Changes

Endpoint auto-detection refactoring

Layer / File(s) Summary
Endpoint path selection with global responses routing
controller/channel-test.go
Refactored requestPath auto-detection logic from independent if statements to a prioritized if/else-if chain covering rerank, embeddings, image generation, codex responses, and compact responses endpoints. Added a new condition that routes to /v1/responses based on service.ShouldChatCompletionsUseResponsesGlobal() global setting.

🎯 2 (Simple) | ⏱️ ~10 minutes

🐰 I hopped through ifs and else,
Now branches line in tidy rows,
A global whisper steps in last,
So responses answer when others pass,
Code neat, the rabbit's work now shows.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: refactoring channel test endpoint detection to honor the global OpenAI Chat Completions to Responses API conversion rule.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@layou233 layou233 force-pushed the channel-test-responses-rule branch from 1808840 to 9ca25e1 Compare May 15, 2026 09:11

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 `@controller/channel-test.go`:
- Around line 122-124: When the branch that calls
channel.ShouldChatCompletionsUseResponsesGlobal(...) sets requestPath =
"/v1/responses", also set the endpointType variable to the responses routing
value so relay mode and request construction stay in sync; update the same
branch that sets requestPath to assign endpointType = "responses" (or the
enum/const your code uses for responses) so buildTestRequest(...) creates a
responses-shaped request and avoids the invalid response request type assertion
in buildTestRequest / later request handling.
🪄 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: 223e7a82-1105-4dc2-9990-7c7ae0d5ec26

📥 Commits

Reviewing files that changed from the base of the PR and between 18282e6 and 1808840.

📒 Files selected for processing (1)
  • controller/channel-test.go

Comment on lines +122 to +124
} else if service.ShouldChatCompletionsUseResponsesGlobal(channel.Id, channel.Type, testModel) {
// follow the global setting for using responses instead of completions
requestPath = "/v1/responses"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Keep endpointType in sync when global responses routing is selected.

This branch sets requestPath to /v1/responses but leaves endpointType empty. At Line 214, buildTestRequest(...) then builds a chat/completions-shaped request, while relay mode is responses; that later fails the type assertion at Lines 323-331 (invalid response request type).

Suggested fix
 		} else if service.ShouldChatCompletionsUseResponsesGlobal(channel.Id, channel.Type, testModel) {
 			// follow the global setting for using responses instead of completions
 			requestPath = "/v1/responses"
+			endpointType = string(constant.EndpointTypeOpenAIResponse)
 		}
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
} else if service.ShouldChatCompletionsUseResponsesGlobal(channel.Id, channel.Type, testModel) {
// follow the global setting for using responses instead of completions
requestPath = "/v1/responses"
} else if service.ShouldChatCompletionsUseResponsesGlobal(channel.Id, channel.Type, testModel) {
// follow the global setting for using responses instead of completions
requestPath = "/v1/responses"
endpointType = string(constant.EndpointTypeOpenAIResponse)
}
🤖 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 `@controller/channel-test.go` around lines 122 - 124, When the branch that
calls channel.ShouldChatCompletionsUseResponsesGlobal(...) sets requestPath =
"/v1/responses", also set the endpointType variable to the responses routing
value so relay mode and request construction stay in sync; update the same
branch that sets requestPath to assign endpointType = "responses" (or the
enum/const your code uses for responses) so buildTestRequest(...) creates a
responses-shaped request and avoids the invalid response request type assertion
in buildTestRequest / later request handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant