fix: handle reasoning-only responses from Gemini 3 Pro Preview #10424
+53
−2
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.
This PR attempts to address Issue #10422 - Gemini Pro failing on both Gemini and OpenRouter.
Problem
When using
google/gemini-3-pro-previewwith high reasoning effort and native tool calling enabled, the model sometimes returns ONLY reasoning content (viareasoning_details) without any text content or tool uses. The current validation inTask.tsonly checks forhasTextContentandhasToolUses, so reasoning-only responses fall through to the error handling path, causing the "Unexpected API Response: The language model did not provide any assistant messages" error.This happens on the second message (and subsequent messages) every time, as confirmed by the reporter.
Solution
Added
reasoningOnlyResponse()helper insrc/core/prompts/responses.ts:Added
hasReasoningcheck insrc/core/task/Task.ts:reasoningMessage.length > 0else if (hasReasoning)block between the successful case and error caseTesting
Notes
This fix allows the task loop to continue instead of failing when the model produces a reasoning-only response. The model is prompted to provide actionable output (tools or text), which should resolve the issue for users with high reasoning effort enabled.
Feedback and guidance are welcome!