Skip to content

fix: disable thinking mode in QwenCodeHandler.completePrompt for prompt enhancement#12105

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/qwen-coder-prompt-enhance-12102
Draft

fix: disable thinking mode in QwenCodeHandler.completePrompt for prompt enhancement#12105
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/qwen-coder-prompt-enhance-12102

Conversation

@roomote-v0
Copy link
Copy Markdown
Contributor

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

This PR attempts to address Issue #12102.

Problem

Prompt enhancement fails with "Failed to enhance prompt" toast when using qwen3-coder models (qwen3-coder-plus, qwen3-coder-flash). The previous fix in #12103 only stripped <think> tags from the response content but did not address the root cause.

Root Cause

qwen3-coder models are thinking/reasoning models. When completePrompt() is called (used for prompt enhancement), the API returns reasoning content in a separate reasoning_content field, potentially leaving message.content empty. Since completePrompt returned message.content || "", an empty string was returned, which the enhancement handler treated as a failure.

Fix

  1. Passes enable_thinking: false in the API request to explicitly disable thinking mode for simple completions. Prompt enhancement does not need the model to reason -- it just needs a direct text response.
  2. Falls back to reasoning_content if content is still empty (in case the API ignores the parameter).
  3. Strips inline <think> blocks as an additional safety net.

Test Plan

  • Added 10 unit tests covering: plain text responses, enable_thinking: false parameter verification, <think> tag stripping, reasoning_content fallback, null/empty content handling, and multiline think blocks.
  • All existing qwen-code tests continue to pass.

Feedback and guidance are welcome.

Interactively review PR in Roo Code Cloud

…pt enhancement

qwen3-coder models are thinking models that return reasoning in a separate
reasoning_content field, which can leave message.content empty. The previous
fix only stripped <think> tags but did not address the root cause.

This change:
- Passes enable_thinking: false to the API to disable thinking mode for
  simple completions (prompt enhancement does not need reasoning)
- Falls back to reasoning_content if content is still empty
- Strips inline <think> blocks as an additional safety net

Closes #12102
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.

1 participant