fix: preserve reasoning.text type in consolidateReasoningDetails for Gemini models#11906
Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
Draft
fix: preserve reasoning.text type in consolidateReasoningDetails for Gemini models#11906roomote-v0[bot] wants to merge 1 commit intomainfrom
roomote-v0[bot] wants to merge 1 commit intomainfrom
Conversation
…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
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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 #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 hadtype: "reasoning.encrypted"but contained a validtextfield (nodata). Now only drops entries with nodataAND notext.2. Fix shared type variable in consolidation loop
A single shared
typevariable was overwritten by the last entry in a group. When a group contained bothreasoning.textandreasoning.encryptedentries at the same index, the text entry type was overwritten toreasoning.encrypted. Now trackstextTypeseparately, and corrects mislabeled entries (reasoning.encryptedwith text content ->reasoning.text).Test Coverage
Added 4 regression tests covering:
reasoning.text+reasoning.encryptedat same indexsanitizeGeminiMessageswith mislabeled entries preserving tool_callsThis 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