Skip to content

fix: use DashScope-compatible parameters in Qwen Code provider (#12067)#12068

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/qwen-code-dashscope-400
Draft

fix: use DashScope-compatible parameters in Qwen Code provider (#12067)#12068
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/qwen-code-dashscope-400

Conversation

@roomote-v0
Copy link
Copy Markdown
Contributor

@roomote-v0 roomote-v0 bot commented Apr 6, 2026

Related GitHub Issue

Closes: #12067

Description

This PR attempts to address Issue #12067 where Qwen Code provider returns 400 Bad Request errors for all requests. Feedback and guidance are welcome.

The root cause is that the Qwen Code provider sends several OpenAI-specific parameters that DashScope's compatible-mode API does not support. This PR makes the following changes to src/api/providers/qwen-code.ts:

  1. max_completion_tokens replaced with max_tokens - DashScope uses the standard max_tokens parameter, not the newer OpenAI-specific max_completion_tokens.
  2. Removed parallel_tool_calls - DashScope does not support this OpenAI-specific parameter.
  3. Removed stream_options - DashScope does not support stream_options: { include_usage: true }.
  4. Overrode convertToolsForOpenAI - DashScope does not support OpenAI's strict: true mode on tool definitions. The override filters for function tools without adding strict mode or schema transformations.

Test Procedure

  • Ran cd src && npx vitest run api/providers/__tests__/qwen-code-native-tools.spec.ts - all 12 tests pass.
  • Updated existing tests that asserted parallel_tool_calls: true to assert it is NOT present.
  • Added new DashScope API Compatibility test suite verifying:
    • max_tokens is used instead of max_completion_tokens
    • stream_options is not included
    • parallel_tool_calls is not included
    • strict: true is not set on tool definitions
    • completePrompt also uses max_tokens

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes.
  • Documentation Impact: No documentation updates are required.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.

Additional Notes

This fix follows the same pattern used by other OpenAI-compatible providers (like LM Studio and Moonshot) that adapt request parameters to match what their target API actually supports.

Interactively review PR in Roo Code Cloud

… 400 errors

Replace OpenAI-specific parameters that DashScope does not support:
- max_completion_tokens -> max_tokens
- Remove parallel_tool_calls (unsupported)
- Remove stream_options (unsupported)
- Override convertToolsForOpenAI to skip strict mode (unsupported)

Fixes #12067
@romandesign
Copy link
Copy Markdown

Is there a way to implement this fix right now, or do I need to wait until a new version is released?

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.

[BUG] Qwen Bad Request 400

2 participants