Skip to content

fix: preserve reasoning effort for chat dialects#1472

Open
kogekiplay wants to merge 1 commit into
BigPizzaV3:mainfrom
kogekiplay:fix/preserve-chat-reasoning-effort
Open

fix: preserve reasoning effort for chat dialects#1472
kogekiplay wants to merge 1 commit into
BigPizzaV3:mainfrom
kogekiplay:fix/preserve-chat-reasoning-effort

Conversation

@kogekiplay

Copy link
Copy Markdown

Summary

  • preserve the standard reasoning_effort value when Responses requests are converted to Chat Completions dialects
  • keep each provider's native reasoning switch (thinking, enable_thinking, or reasoning_split) unchanged
  • cover both Responses and Chat Completions upstream routes with xhigh regression tests

Problem

Codex sends the selected effort as reasoning.effort. During Responses-to-Chat conversion, dialects such as GLM, Kimi, Qwen, and MiniMax reduced that value to a provider-specific boolean switch. The exact effort level was therefore lost, so downstream proxies and monitoring could observe none, auto, or no effort even when the client selected xhigh.

Compatibility

This adds reasoning_effort alongside the existing native provider field. DeepSeek/OpenRouter handling and disabled reasoning values remain unchanged.

Verification

  • cargo fmt --check
  • cargo test -p codex-plus-core
  • GIT_CONFIG_COUNT=1 GIT_CONFIG_KEY_0=commit.gpgsign GIT_CONFIG_VALUE_0=false cargo test --workspace
  • npm run check
  • npm run vite:build

@kogekiplay kogekiplay marked this pull request as ready for review July 13, 2026 07:21
@BigPizzaV3

Copy link
Copy Markdown
Owner

感谢贡献。这个 PR 的目标可以理解,但当前实现存在一个兼容性阻塞,暂不建议合并。

protocol_proxy.rs 新增的分支会对以下三类方言无条件附加顶层 reasoning_effort

  • Kimi / GLM / MiMo:thinking
  • Qwen / SiliconFlow:enable_thinking
  • MiniMax:reasoning_split

这些上游通常只支持自己的原生开关字段,严格接口可能因为未知的 reasoning_effort 参数直接返回 400。主分支原本对 Kimi 明确断言 reasoning_effort 不存在,这个 PR 攋掉了该兼容边界,但没有提供对应官方接口接受此字段的依据。

这也与 CC-Switch 当前实现相反:CC-Switch 对 Kimi、GLM、Qwen、MiniMax、MiMo 和 SiliconFlow 明确使用 supports_effort: Some(false),转换时只有 supports_effort=true 才会发送 effort 字段:
https://github.com/farion1231/cc-switch/blob/c6197ae32450cd70e2bf03b35e3f5f53ac12044c/src-tauri/src/proxy/providers/transform_codex_chat.rs#L364-L430

当前新增测试只验证 mock 收到了 reasoning_effort,mock 不会模拟严格上游拒绝未知字段;Responses 上游用例验证的则是原本已有的纯透传行为,不能证明这 5 行修改兼容真实接口。

建议改为供应商级能力控制:

  1. 增加类似 supports_effort 的配置,默认关闭。
  2. 只有明确确认支持时才发送 reasoning_effort
  3. 如果需求来自某些中转站,应按供应商 opt-in,不能仅根据模型名对所有直连上游开启。
  4. 增加“不支持 effort 时不发送”和严格上游拒绝未知字段的回归测试。

修正这个边界后再考虑合并。

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