Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Dec 4, 2025

This PR attempts to address Issue #9822. Feedback and guidance are welcome!

Problem

The Gemini provider was emitting duplicate text when streaming responses. This occurred when the API response chunks contained both candidates with structured content AND a fallback text property with the same content, causing the text to be yielded twice.

Solution

Added a processedContent flag to track whether any content was yielded from the structured candidates processing. The fallback to chunk.text now only occurs when no content was processed from candidates, preventing duplicate text emission.

Changes

  • Modified src/api/providers/gemini.ts to add duplicate prevention logic
  • Added comprehensive test cases in src/api/providers/__tests__/gemini.spec.ts to verify the fix

Testing

  • Added test case to verify no duplication when both candidates and text are present
  • Added test case to verify fallback still works when only text property is present
  • All existing tests continue to pass

Fixes #9822

…sing

- Added processedContent flag to track if content was yielded from candidates
- Only fallback to chunk.text when no content was processed from candidates
- Added comprehensive test cases to verify the fix
- Fixes issue #9822 where responses were being duplicated when both candidates and text properties were present
@roomote
Copy link
Contributor Author

roomote bot commented Dec 4, 2025

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found. The fix correctly prevents duplicate text emission by tracking whether content was processed from the structured candidates before falling back to the text property.

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 4, 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.

[BUG] Repeated response

3 participants