fix: preserve tool calls when thinking models return no text content#11866
Merged
fix: preserve tool calls when thinking models return no text content#11866
Conversation
…thout text Two bugs caused Qwen3-Coder (and similar thinking models) to silently drop tool calls: 1. Ollama: When the model produces thinking content and tool calls but no text content, the early return in convertChatMessage only yielded the thinking message, discarding tool calls entirely. 2. OpenAI/vLLM: fromChatCompletionChunk used an if/else chain where content was checked before tool_calls, so any chunk with both fields would lose its tool calls. Fixes #8744
Contributor
|
Docs Review: No documentation updates needed. This PR fixes an internal bug in the LLM streaming logic for thinking models (Ollama and OpenAI/vLLM providers). The changes ensure tool calls are preserved when thinking models return thinking content without text content. These are implementation-level fixes that don't affect any user-facing APIs, configuration options, or documented behavior—users will simply see tool calling work correctly in edge cases where it was previously broken. |
The vLLM "list index out of range" error is server-side (Python), not fixable by reordering client-side chunk parsing. Keep only the Ollama fix which addresses the confirmed bug.
Patrick-Erichsen
approved these changes
Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When Qwen3-Coder (or similar thinking models) returns thinking content + tool calls but no text content via Ollama, the early return in
convertChatMessageonly yielded the thinking message, silently discarding tool calls. This caused the agent spinner to never stop and tools to never execute.Fix: Add
!toolCalls?.lengthto the early return condition so tool calls are preserved even when thinking is present without text content.Note: The vLLM users in #8744 see a server-side Python error (
list index out of range) which is not fixable client-side — they likely need--tool-call-parserconfigured on vLLM.Fixes #8744 (Ollama users)
Also related:
Test plan