Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Dec 31, 2025

This PR attempts to address Issue #10422 - Gemini Pro failing on both Gemini and OpenRouter.

Problem

When using google/gemini-3-pro-preview with high reasoning effort and native tool calling enabled, the model sometimes returns ONLY reasoning content (via reasoning_details) without any text content or tool uses. The current validation in Task.ts only checks for hasTextContent and hasToolUses, 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

  1. Added reasoningOnlyResponse() helper in src/core/prompts/responses.ts:

    • Prompts the model to continue with actionable output after a reasoning-only response
    • Instructs the model to use tools or provide text content
  2. Added hasReasoning check in src/core/task/Task.ts:

    • New variable that checks if reasoningMessage.length > 0
    • Added else if (hasReasoning) block between the successful case and error case
    • When reasoning-only response is detected:
      • Reset error counters (valid response received)
      • Save assistant message with reasoning to API history
      • Add prompting message to continue with actionable output
      • Continue the task loop instead of failing

Testing

  • TypeScript compilation passes
  • All 122 existing Task tests pass
  • No regressions introduced

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!

When using Gemini 3 Pro Preview with high reasoning effort and native tool
calling enabled, the model sometimes returns ONLY reasoning content without
any text or tool uses. This caused the "Unexpected API Response: The language
model did not provide any assistant messages" error.

Changes:
- Add reasoningOnlyResponse() helper to responses.ts that prompts the model
  to continue with actionable output after a reasoning-only response
- Add hasReasoning check in Task.ts validation logic (line 3219)
- Handle reasoning-only responses by saving the assistant message with
  reasoning to history and prompting the model to continue with tools/text

This fix allows the task loop to continue instead of failing when the model
produces a reasoning-only response.

Fixes #10422
@roomote
Copy link
Contributor Author

roomote bot commented Dec 31, 2025

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The implementation correctly handles reasoning-only responses from Gemini 3 Pro Preview by detecting when the model returns only reasoning content (without text or tool uses), saving the reasoning to API history, and prompting the model to continue with actionable output.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Dec 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

3 participants