Skip to content

fix(channel-test): 修复模型测试codex失败,导致codex模型无法使用问题 - #2625

Closed
Caisin wants to merge 1 commit into
QuantumNous:mainfrom
Caisin:fix/channel-test-codex
Closed

Caisin wants to merge 1 commit into
QuantumNous:mainfrom
Caisin:fix/channel-test-codex

Conversation

@Caisin

@Caisin Caisin commented Jan 10, 2026 •

Copy link
Copy Markdown
Contributor

Summary by CodeRabbit

  • Tests
    • Improved test coverage for streaming response handling with structured message payloads for OpenAI-compatible endpoints.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 10, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

Modified the buildTestRequest function in the test file to alter request payload format for OpenAI and codex endpoint types. Changed the Input field from a plain JSON string to a structured JSON array containing message payloads and added a Stream: true field to enable streaming behavior for test cases.

Changes

Cohort / File(s) Summary
Test Request Payload Updates
controller/channel-test.go
Modified buildTestRequest function to update Input field format from plain JSON string to structured message array for OpenAIResponse and codex endpoint types; added Stream: true field for streaming support in test requests.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • creamlike1024
  • xyfacai

Poem

🐰 A test request hops with grace,
Streaming now at rapid pace,
Structured messages in array form,
No plain strings to transform,
Payloads dance, oh what a race! 🚀

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is partially related to the changeset. It mentions fixing codex model testing failures, which aligns with the PR's focus on modifying test request handling for codex responses, but is written in Chinese and lacks complete clarity about the specific technical change (Input field restructuring and Stream flag addition).
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing touches
  • 📝 Generate docstrings

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.

@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: 0

🧹 Nitpick comments (1)
controller/channel-test.go (1)

433-439: Extract Responses Input constant and reconsider Stream: true default for test

The hard-coded json.RawMessage literal is duplicated across lines 437 and 476, creating a maintenance risk. Additionally, forcing Stream: true in test payloads contradicts the OpenAI Responses API default (stream=false) and may hide edge cases where streaming is not supported—a more conservative test strategy would default to Stream: false.

Proposed refactor
+var defaultResponsesTestInput = json.RawMessage(
+	`[{"type":"message","role":"user","content":[{"type":"input_text","text":"hi"}]}]`,
+)
+
 func buildTestRequest(model string, endpointType string, channel *model.Channel) dto.Request {
 	// 根据端点类型构建不同的测试请求
 	if endpointType != "" {
 		switch constant.EndpointType(endpointType) {
 ...
 		case constant.EndpointTypeOpenAIResponse:
 			// 返回 OpenAIResponsesRequest
 			return &dto.OpenAIResponsesRequest{
 				Model:  model,
-				Input:  json.RawMessage(`[{"type":"message","role":"user","content":[{"type":"input_text","text":"hi"}]}]`),
-				Stream: true,
+				Input:  defaultResponsesTestInput,
+				Stream: false,
 			}
 ...
 	// Responses-only models (e.g. codex series)
 	if strings.Contains(strings.ToLower(model), "codex") {
 		return &dto.OpenAIResponsesRequest{
 			Model:  model,
-			Input:  json.RawMessage(`[{"type":"message","role":"user","content":[{"type":"input_text","text":"hi"}]}]`),
-			Stream: true,
+			Input:  defaultResponsesTestInput,
+			Stream: false,
 		}
 	}
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1a5c8f3 and 2a0016c.

📒 Files selected for processing (1)
  • controller/channel-test.go
🧰 Additional context used
🧬 Code graph analysis (1)
controller/channel-test.go (1)
dto/openai_request.go (1)
  • Input (904-908)

@seefs001

Copy link
Copy Markdown
Collaborator

https://platform.openai.com/docs/api-reference/responses/create

单字符串在input是官方最小案例,你不支持或许只是你的供应商不支持,但是responses接口格式支持的,这里测试的原则是尽可能发送最少token

@Caisin

Caisin commented Jan 10, 2026

Copy link
Copy Markdown
Contributor Author

https://platform.openai.com/docs/api-reference/responses/create

单字符串在input是官方最小案例,你不支持或许只是你的供应商不支持,但是responses接口格式支持的,这里测试的原则是尽可能发送最少token
改成默认用原来的,如果失败再用我这个模式去测试,可以合并吗?
后面其它用户可能也会遇到这个问题
如果不能合并的话,只能自己维护一个新的分支了

@seefs001

Copy link
Copy Markdown
Collaborator

https://platform.openai.com/docs/api-reference/responses/create
单字符串在input是官方最小案例,你不支持或许只是你的供应商不支持,但是responses接口格式支持的,这里测试的原则是尽可能发送最少token
改成默认用原来的,如果失败再用我这个模式去测试,可以合并吗?
后面其它用户可能也会遇到这个问题
如果不能合并的话,只能自己维护一个新的分支了

我在考虑把参数覆盖功能也给套到这个上面,这样就可以改配置实现你这个了

@Caisin

Caisin commented Jan 10, 2026

Copy link
Copy Markdown
Contributor Author

https://platform.openai.com/docs/api-reference/responses/create
单字符串在input是官方最小案例,你不支持或许只是你的供应商不支持,但是responses接口格式支持的,这里测试的原则是尽可能发送最少token
改成默认用原来的,如果失败再用我这个模式去测试,可以合并吗?
后面其它用户可能也会遇到这个问题
如果不能合并的话,只能自己维护一个新的分支了

我在考虑把参数覆盖功能也给套到这个上面,这样就可以改配置实现你这个了

好的,感谢大佬! 等您好消息 🤝

@seefs001

seefs001 commented Jan 10, 2026 •

Copy link
Copy Markdown
Collaborator

可以看一下这个PR #2627 配置参数覆盖,下面的效果是当是渠道测试请求时,模型名包含codex,则设置input为你前面要的内容
{ "operations": [ { "path": "input", "mode": "set", "value": [ { "type": "message", "role": "user", "content": [ { "type": "input_text", "text": "hi" } ] } ], "conditions": [ { "path": "model", "mode": "contains", "value": "codex" }, { "path": "is_channel_test", "mode": "full", "value": true } ], "logic": "AND" } ] }

@Caisin

Caisin commented Jan 10, 2026

Copy link
Copy Markdown
Contributor Author

可以看一下这个PR #2627 配置参数覆盖,下面的效果是当是渠道测试请求时,模型名包含codex,则设置input为你前面要的内容 { "operations": [ { "path": "input", "mode": "set", "value": [ { "type": "message", "role": "user", "content": [ { "type": "input_text", "text": "hi" } ] } ], "conditions": [ { "path": "model", "mode": "contains", "value": "codex" }, { "path": "is_channel_test", "mode": "full", "value": true } ], "logic": "AND" } ] }

好的,感谢大佬!
还有个需求,有些渠道校验了只能从Claude Code Cli和Codex Cli的请求头才能访问,导致测试不通过,需要加下测试请求头覆盖的功能

@seefs001

Copy link
Copy Markdown
Collaborator

可以看一下这个PR #2627 配置参数覆盖,下面的效果是当是渠道测试请求时,模型名包含codex,则设置input为你前面要的内容 { "operations": [ { "path": "input", "mode": "set", "value": [ { "type": "message", "role": "user", "content": [ { "type": "input_text", "text": "hi" } ] } ], "conditions": [ { "path": "model", "mode": "contains", "value": "codex" }, { "path": "is_channel_test", "mode": "full", "value": true } ], "logic": "AND" } ] }

好的,感谢大佬! 还有个需求,有些渠道校验了只能从Claude Code Cli和Codex Cli的请求头才能访问,导致测试不通过,需要加下测试请求头覆盖的功能

这个之前就是有的吧,可以试试

@seefs001 seefs001 closed this Jan 10, 2026
@Caisin
Caisin deleted the fix/channel-test-codex branch January 13, 2026 11:58
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.

2 participants