Skip to content

fix: preserve reasoning.text type in consolidateReasoningDetails for Gemini models#11906

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/gemini-reasoning-details-11629
Draft

fix: preserve reasoning.text type in consolidateReasoningDetails for Gemini models#11906
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/gemini-reasoning-details-11629

Conversation

@roomote-v0
Copy link
Contributor

@roomote-v0 roomote-v0 bot commented Mar 10, 2026

This PR attempts to address Issue #11629 by fixing two bugs in consolidateReasoningDetails() that caused assistant content to be stripped on Turn 2 for Gemini models via OpenRouter.

Changes

1. Fix corrupted block filter (line 53)

The filter previously dropped entries where type === "reasoning.encrypted" && !detail.data. This incorrectly dropped mislabeled text entries that had type: "reasoning.encrypted" but contained a valid text field (no data). Now only drops entries with no data AND no text.

2. Fix shared type variable in consolidation loop

A single shared type variable was overwritten by the last entry in a group. When a group contained both reasoning.text and reasoning.encrypted entries at the same index, the text entry type was overwritten to reasoning.encrypted. Now tracks textType separately, and corrects mislabeled entries (reasoning.encrypted with text content -> reasoning.text).

Test Coverage

Added 4 regression tests covering:

  • Mixed reasoning.text + reasoning.encrypted at same index
  • Mislabeled text entries (type=reasoning.encrypted with text but no data)
  • Truly corrupted blocks still dropped (no data AND no text)
  • End-to-end sanitizeGeminiMessages with mislabeled entries preserving tool_calls

This is essentially the same fix as #11650, rebased onto the current main branch. Feedback and guidance are welcome.

Interactively review PR in Roo Code Cloud

…Gemini models

Fixes two bugs in consolidateReasoningDetails() that caused assistant
content to be stripped on Turn 2 for Gemini models via OpenRouter:

1. The corrupted block filter dropped entries with type=reasoning.encrypted
   that had a text field but no data field. These are mislabeled text
   entries, not truly corrupted. Now only drops entries with no data AND
   no text.

2. A shared type variable caused reasoning.text entries to be overwritten
   with reasoning.encrypted when grouped at the same index. Now tracks
   textType separately from encrypted entry types.

Closes #11629
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