fix: unescape HTML entities in Gemini provider streaming responses #8108
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.
Description
This PR fixes an issue where square brackets and other special characters were being stripped from code when using Google Gemini models. The problem affected multiple programming languages including Python, as reported in issue #8107.
Problem
When using Gemini API with Roo Code to generate or modify code containing arrays or indexing operations, the square brackets were missing from the output. For example:
populated_variable[0]populated_variableRoot Cause
Gemini API returns square brackets as HTML entities (
[,],[,]) in its responses. While PR #7577 fixed this for C# by updating theunescapeHtmlEntitiesfunction, the fix wasn't being applied to the streamed text from the Gemini provider itself.Solution
Applied the existing
unescapeHtmlEntitiesfunction to all text yielded from the Gemini API:createMessagemethod for streaming responses (both regular content and thinking/reasoning parts)completePromptmethod for non-streaming responsesChanges
unescapeHtmlEntitiesimport and applied it to all text outputsTesting
Verification
The fix has been validated to correctly handle:
[,][,]<,>,&, etc.Fixes #8107
Important
Fixes HTML entity unescaping in Gemini provider responses, ensuring correct handling of square brackets and other entities in
gemini.ts.unescapeHtmlEntitiesto all text outputs increateMessageandcompletePromptmethods ingemini.ts.gemini.spec.tsto verify HTML entity unescaping in text messages, Python code, named entities, reasoning parts, and complete prompt responses.This description was created by
for d671376. You can customize this summary. It will automatically update as commits are pushed.