mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-08-22 23:25:28 +00:00
fix(core): avoid required tools in DashScope thinking (#7661)
Co-authored-by: JS van Dijk <267467744+hogeheer499-commits@users.noreply.github.com>
This commit is contained in:
parent
ecd86421c5
commit
9d19eafa97
2 changed files with 32 additions and 4 deletions
|
|
@ -722,6 +722,28 @@ describe('ContentGenerationPipeline', () => {
|
|||
expectedThinking: true,
|
||||
expectedToolChoice: undefined,
|
||||
},
|
||||
{
|
||||
name: 'remove required tool selection when thinking is enabled on the wire',
|
||||
baseUrl: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
|
||||
model: 'qwen3.7-max',
|
||||
extraBody: { enable_thinking: true },
|
||||
thinkingMandatory: undefined,
|
||||
reasoning: undefined,
|
||||
includeThoughts: true,
|
||||
expectedThinking: true,
|
||||
expectedToolChoice: undefined,
|
||||
},
|
||||
{
|
||||
name: 'preserve required tool selection when thinking is not enabled',
|
||||
baseUrl: 'https://dashscope.aliyuncs.com/compatible-mode/v1',
|
||||
model: 'qwen3.7-max',
|
||||
extraBody: undefined,
|
||||
thinkingMandatory: undefined,
|
||||
reasoning: undefined,
|
||||
includeThoughts: true,
|
||||
expectedThinking: undefined,
|
||||
expectedToolChoice: 'required',
|
||||
},
|
||||
{
|
||||
name: 'never emit the disable even under the reasoning opt-out',
|
||||
baseUrl:
|
||||
|
|
|
|||
|
|
@ -955,10 +955,16 @@ export class ContentGenerationPipeline {
|
|||
delete typed['chat_template_kwargs'];
|
||||
}
|
||||
}
|
||||
// DashScope rejects forced tool selection while thinking is enabled.
|
||||
if (isDashScope && typed['tool_choice'] === 'required') {
|
||||
delete typed['tool_choice'];
|
||||
}
|
||||
}
|
||||
|
||||
const typed = providerRequest as unknown as Record<string, unknown>;
|
||||
// DashScope rejects forced tool selection while thinking is enabled.
|
||||
if (
|
||||
isDashScope &&
|
||||
typed['tool_choice'] === 'required' &&
|
||||
(thinkingMandatory || typed['enable_thinking'] === true)
|
||||
) {
|
||||
delete typed['tool_choice'];
|
||||
}
|
||||
|
||||
return providerRequest;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue