Skip to content

fix(channel): 修复 channel test 在 model_mapping 场景下(gpt-5.3-codex => deepseek-v4)端点推断错误的问题 - #4492

Open
luozhihua wants to merge 6 commits into
QuantumNous:mainfrom
luozhihua:main
Open

luozhihua wants to merge 6 commits into
QuantumNous:mainfrom
luozhihua:main

Conversation

@luozhihua

@luozhihua luozhihua commented Apr 27, 2026 •

Copy link
Copy Markdown

⚠️ 提交说明 / PR Notice

Important

  • 请提供人工撰写的简洁摘要,避免直接粘贴未经整理的 AI 输出。

📝 变更描述 / Description

本次修改修复了 channel test 在存在 model_mapping 时的自动端点推断问题。

问题在于:当未显式传入 endpoint_type 时,testChannel 会先根据原始测试模型名推断请求路径,再应用 channel 的 model_mapping。
例如测试模型为 gpt-5.3-codex,并映射到 deepseek-v4-pro 时,原逻辑会先因为模型名包含 codex 而推断出 /v1/responses,随后才将模型映射为 deepseek-v4-pro。这样最终会把 DeepSeek 渠道请求错误地发送到 responses 路径,导致 404。

本 PR 的修改方式是:

  • 在未显式指定 endpoint_type 时,先解析 model_mapping 得到最终上游模型
  • 再基于映射后的模型推断自动测试请求路径
  • 使用映射后的模型构造测试请求
  • 保持显式传入 endpoint_type 时的原有行为不变
  • 保持 Codex 渠道默认走 responses 端点的行为不变

同时补充了回归测试,覆盖:

  • gpt-5.3-codex -> deepseek-v4-pro 时应走 chat completions 路径
  • Codex 渠道仍然默认走 responses 端点

🚀 变更类型 / Type of change

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

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

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

📸 运行证明 / Proof of Work

Issue 中的复现请求示例:

GET /api/channel/test/11?model=gpt-5.3-codex

📸 运行证明 / Proof of Work

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

image

Codex官方渠道正常:
image

Summary by CodeRabbit

  • Refactor

    • Improved internal channel testing logic structure and model handling.
  • Tests

    • Added test coverage for automatic channel detection with model mapping and request routing.

@coderabbitai

coderabbitai Bot commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

Refactors channel test's automatic endpoint detection to resolve model mappings before determining request paths, ensuring the endpoint selection uses the final mapped model rather than the original model name.

Changes

Cohort / File(s) Summary
Automatic model resolution and path detection
controller/channel-test.go
Extracts two new helper functions: resolveAutomaticChannelTestModel() resolves the effective model name via optional modelMapping chain traversal and suffix normalization; detectAutomaticChannelTestRequestPath() derives the target path based on the resolved model and channel type. Refactors testChannel to compute requestModel upfront when endpointType is unspecified, using it for both path detection and request construction instead of inline heuristics.
Validation tests
controller/channel_test_internal_test.go
Adds two test cases validating automatic detection: (1) ModelMapping correctly maps input model to target and selects appropriate path; (2) Codex channel type preserves response routing. Updates imports to include constant and model.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • PR #1995: Modifies controller/channel-test.go's testModel resolution and request-path selection logic, directly related to this PR's refactoring of model and endpoint detection.

Poem

🐰 A codex mapped through channels deep,
Now finds its path with model heap,
No more mismatches in the test,
The mapped model knows what's best! ✨

🚥 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 fix: resolving endpoint inference errors in channel tests when model_mapping is applied (gpt-5.3-codex mapped to deepseek-v4), which matches the changeset's core refactoring of model resolution logic.
Linked Issues check ✅ Passed The PR fully addresses issue #4487 by implementing automatic model resolution through mapping before endpoint detection, preserving explicit endpoint_type behavior, and adding regression tests covering the gpt-5.3-codex to deepseek-v4-pro scenario.
Out of Scope Changes check ✅ Passed All changes are directly scoped to fixing the model_mapping endpoint inference issue: refactoring testChannel logic, adding helper functions for model/path resolution, and adding relevant test cases.

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

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

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.

🧹 Nitpick comments (1)
controller/channel_test_internal_test.go (1)

75-95: LGTM — focused regression coverage for the reported bug.

TestResolveAutomaticChannelTestModelAppliesModelMapping exercises the exact scenario from #4487 (gpt-5.3-codex → deepseek-v4-pro resolves to /v1/chat/completions), and TestNormalizeChannelTestEndpointKeepsCodexChannelOnResponses pins the unchanged Codex default.

Optional follow-ups (not blocking):

  • Add a chain mapping case (a → b → c) to lock in the chain-traversal behavior of resolveAutomaticChannelTestModel.
  • Add a cycle case (a → b → a) to document that cycles short-circuit safely without panicking.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@controller/channel_test_internal_test.go` around lines 75 - 95, Add two
additional unit tests to cover mapping chains and cycles for
resolveAutomaticChannelTestModel: create a test that verifies a chain mapping
(e.g., "a" -> "b", "b" -> "c") resolves "a" to "c" and another test that
verifies a cycle (e.g., "a" -> "b", "b" -> "a") short-circuits safely without
panic and returns a stable value; locate and update tests near
TestResolveAutomaticChannelTestModelAppliesModelMapping and use the same helpers
(resolveAutomaticChannelTestModel and detectAutomaticChannelTestRequestPath) to
assert resolvedModel and requestPath behavior.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@controller/channel_test_internal_test.go`:
- Around line 75-95: Add two additional unit tests to cover mapping chains and
cycles for resolveAutomaticChannelTestModel: create a test that verifies a chain
mapping (e.g., "a" -> "b", "b" -> "c") resolves "a" to "c" and another test that
verifies a cycle (e.g., "a" -> "b", "b" -> "a") short-circuits safely without
panic and returns a stable value; locate and update tests near
TestResolveAutomaticChannelTestModelAppliesModelMapping and use the same helpers
(resolveAutomaticChannelTestModel and detectAutomaticChannelTestRequestPath) to
assert resolvedModel and requestPath behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: db9afc8e-e336-4a08-af68-b1c7cbe37a98

📥 Commits

Reviewing files that changed from the base of the PR and between e36d191 and bcf9aed.

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

@seefs001 seefs001 self-assigned this Apr 27, 2026
@Calcium-Ion
Calcium-Ion force-pushed the main branch 2 times, most recently from 51fdfc5 to 2b6f1df Compare August 30, 2026 15:03
soulteary added a commit to soulteary/yunqi that referenced this pull request Nov 22, 2026
docs: finalize community improvement batches and validation

Document eight implemented capabilities, review fixes, exact commits, CI evidence and upstream correspondence. Preserve identity, Redis and evaluation boundaries, and provide the model governance lifecycle/API guide.

All functional PRs were reviewed and merged after successful regression tests and Verify CI. The running checkout and services were not changed.

Refs: QuantumNous/new-api issue #1730 QuantumNous/new-api#1730
Refs: QuantumNous/new-api issue #2841 QuantumNous/new-api#2841
Refs: QuantumNous/new-api issue #3240 QuantumNous/new-api#3240
Refs: QuantumNous/new-api PR #3345 QuantumNous/new-api#3345
Refs: QuantumNous/new-api issue #4328 QuantumNous/new-api#4328
Refs: QuantumNous/new-api PR #4329 QuantumNous/new-api#4329
Refs: QuantumNous/new-api PR #4492 QuantumNous/new-api#4492
Refs: QuantumNous/new-api PR #5431 QuantumNous/new-api#5431
Refs: QuantumNous/new-api PR #5791 QuantumNous/new-api#5791
Refs: QuantumNous/new-api PR #6264 QuantumNous/new-api#6264
Refs: QuantumNous/new-api PR #6583 QuantumNous/new-api#6583
Refs: QuantumNous/new-api PR #6620 QuantumNous/new-api#6620
Refs: QuantumNous/new-api PR #6673 QuantumNous/new-api#6673
Refs: QuantumNous/new-api issue #6972 QuantumNous/new-api#6972
Refs: QuantumNous/new-api PR #7028 QuantumNous/new-api#7028
Refs: QuantumNous/new-api issue #7951 QuantumNous/new-api#7951
Refs: QuantumNous/new-api issue #7952 QuantumNous/new-api#7952
Refs: QuantumNous/new-api PR #7953 QuantumNous/new-api#7953
Refs: QuantumNous/new-api PR #7955 QuantumNous/new-api#7955
Refs: QuantumNous/new-api issue #8034 QuantumNous/new-api#8034
Refs: QuantumNous/new-api PR #8076 QuantumNous/new-api#8076
Refs: QuantumNous/new-api issue #8123 QuantumNous/new-api#8123
Refs: QuantumNous/new-api PR #8124 QuantumNous/new-api#8124
Refs: QuantumNous/new-api issue #8232 QuantumNous/new-api#8232
Refs: QuantumNous/new-api PR #8233 QuantumNous/new-api#8233
Refs: QuantumNous/new-api issue #8295 QuantumNous/new-api#8295
Refs: QuantumNous/new-api PR #8296 QuantumNous/new-api#8296
Refs: QuantumNous/new-api PR #8350 QuantumNous/new-api#8350
Refs: QuantumNous/new-api PR #8357 QuantumNous/new-api#8357
Refs: QuantumNous/new-api PR #8363 QuantumNous/new-api#8363
Refs: #99 #99
Refs: #100 #100
Refs: #101 #101
Refs: #102 #102
Refs: #103 #103
Refs: #104 #104
Refs: #105 #105
Refs: #106 #106
Refs: #107 #107
Refs: #108 #108

Refs: #109 #109

Documentation Verify CI passed: https://github.com/soulteary/yunqi/actions/runs/45003986698

This branch has not been deployed

No deployments
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.

DeepSeek V4 channel test returns 404 when gpt-5.3-codex is mapped to deepseek-v4-pro

2 participants