fix(core): avoid required tools in DashScope thinking - #7661
Conversation
|
Thanks for the PR! Template looks good ✓ Problem: observed bug with solid evidence. Issue #7659 documents the exact 400 rejection from DashScope when Direction: aligned. The fix direction was explicitly endorsed by a maintainer in #7659, who provided the exact guard condition this PR implements. CHANGELOG has no direct reference, but DashScope provider compatibility is squarely within scope. Size: 14 production lines (pipeline.ts: +10/−4), 22 test lines (pipeline.test.ts: +22). Well under any threshold. Approach: the scope feels right — move the existing Moving on to code review. 🔍 中文说明感谢贡献! 模板完整 ✓ 问题:已观测到的 bug,有充分证据。Issue #7659 记录了 DashScope 在 wire 上有 方向:对齐。修复方向已在 #7659 中获得维护者明确认可,维护者提供了与本 PR 实现完全一致的守卫条件。CHANGELOG 无直接引用,但 DashScope 提供商兼容性完全在范围内。 规模:14 行生产代码(pipeline.ts: +10/−4),22 行测试代码(pipeline.test.ts: +22)。远低于任何阈值。 方案:范围合理——将现有的 进入代码审查 🔍 — Qwen Code · qwen3.8-max-preview Reviewed at |
Code ReviewIndependent proposal: given the problem (DashScope Comparison: the PR does exactly this. The The two new test cases slot into the existing
The existing test "still force-disable hybrid models that only declare extra_body.enable_thinking" ( No correctness bugs, no security concerns, no convention violations. The change is the exact fix the maintainer prescribed in #7659. TestingCI check results for
No failures. The ubuntu test suite (which includes the pipeline tests) passes. Real-scenario testing: N/A — this is a provider-level wire format change (request body field stripping), not a TUI-visible behavior. The unit tests directly assert the outgoing request shape. 中文说明代码审查独立方案: 针对此问题(DashScope 的 对比: PR 完全按照此方案实现。 两个新测试用例插入现有的
现有测试"still force-disable hybrid models that only declare extra_body.enable_thinking"( 无正确性 bug,无安全隐患,无规范违反。此变更正是维护者在 #7659 中开出的修复方案。 测试
真实场景测试:不适用——这是提供商级别的 wire 格式变更(请求体字段移除),非 TUI 可见行为。单元测试直接断言了发出的请求形状。 — Qwen Code · qwen3.8-max-preview Reviewed at |
|
Confidence: 5/5 — clean across every stage; the exact fix the maintainer prescribed, with regression tests for both branches. This is a textbook minimal bugfix. The problem is real and well-documented (#7659, maintainer-confirmed), the fix is the one-line guard broadening the maintainer wrote out in the issue, and the tests cover the thinking-on-wire and no-thinking paths. Fourteen production lines, no unrelated edits, no new abstractions. If I had to maintain this in six months, I'd thank the author — the guard reads naturally and the comment explains the DashScope constraint. The only thing I checked carefully was whether the relocated guard could regress the existing "force-disable hybrid models" test (where LGTM, approving. ✅ 中文说明置信度:5/5 —— 各阶段均无问题;正是维护者开出的修复方案,两个分支均有回归测试。 这是一个教科书式的最小 bugfix。问题真实且有充分记录(#7659,维护者已确认),修复方案就是维护者在 issue 中写出的那一行守卫扩展,测试覆盖了 thinking-on-wire 和 no-thinking 两条路径。14 行生产代码,无无关编辑,无新抽象。如果半年后维护这段代码,我会感谢作者——守卫条件读起来自然,注释解释了 DashScope 的约束。 我唯一仔细检查的是重定位后的守卫是否会使现有的"force-disable hybrid models"测试回归( LGTM,批准合并。✅ — Qwen Code · qwen3.8-max-preview Reviewed at |
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
LGTM, looks ready to ship. ✅
qwen-code-ci-bot
left a comment
There was a problem hiding this comment.
No issues found. LGTM! ✅
— qwen3.7-max via Qwen Code /review
Code Review —
|
doudouOUC
left a comment
There was a problem hiding this comment.
No issues found. LGTM! ✅
— qwen3.7-max via Qwen Code /review
Review + live DashScope API verification report (real key, real build, tmux)Verdict: the fix is correct, and I verified every link of its causal chain against the live DashScope API — the premise (400), the transformation's validity (200 + tool still called), and the control (required preserved without thinking). Code review reasoning
Verification evidence (Linux, commit c30de11)Live DashScope API (
Unit: tmux E2E (full build + bundle, isolated HOME, real DashScope provider): interactive session on NoteThe linked issue's failure mode (thinking enabled via |
|
Released in v0.21.1. |
|
|
What this PR does
When a DashScope request has thinking enabled, it no longer sends a forced
tool_choice: "required". Forced tool selection stays unchanged when thinking is off and for non-DashScope providers.Why it's needed
Structured side queries such as memory recall use forced tool selection. DashScope rejects that setting while thinking is active, so users who enable thinking without also setting the separate mandatory-thinking option receive a 400 response. The previous safeguard only recognized the mandatory-thinking option instead of the final request state.
Reviewer Test Plan
How to verify
Configure a DashScope model with thinking enabled but without mandatory thinking, then issue a structured side query using forced function calling. The outgoing request should keep thinking enabled and omit forced tool selection. Repeat without thinking enabled and confirm that forced tool selection is still present.
Evidence (Before & After)
Before, the reproduced wire shape contained
{ enable_thinking: true, tool_choice: "required" }, which DashScope rejects. After, the focused pipeline suite confirms that the same thinking request omitstool_choice, while the non-thinking control keeps it. The focused suite passes 122/122 tests.Tested on
Environment (optional)
Node.js 22.22.1 and npm 10.9.4.
Risk & Scope
Linked Issues
Fixes #7659
中文说明
本 PR 的改动
当 DashScope 请求已启用思考时,不再发送强制的
tool_choice: "required"。未启用思考时,以及非 DashScope 提供商的行为保持不变。为什么需要此改动
记忆召回等结构化侧查询会使用强制工具选择。DashScope 在启用思考时会拒绝该设置,因此只启用思考、但没有另外设置强制思考选项的用户会收到 400 响应。之前的保护逻辑只识别强制思考选项,而没有检查最终请求的实际状态。
审查者测试计划
如何验证
配置一个启用思考但未启用强制思考的 DashScope 模型,然后使用强制函数调用发起结构化侧查询。发出的请求应保留思考设置,并省略强制工具选择。随后在未启用思考的情况下重复测试,确认强制工具选择仍然存在。
证据(改动前后)
改动前,复现出的请求包含
{ enable_thinking: true, tool_choice: "required" },DashScope 会拒绝该组合。改动后,针对性的 pipeline 测试确认相同的思考请求会省略tool_choice,而非思考对照请求仍然保留该字段。针对性测试共 122 项,全部通过。测试平台
环境(可选)
Node.js 22.22.1 和 npm 10.9.4。
风险与范围
关联 Issue
Fixes #7659