Repository navigation
[SSR Agent] Issue Fix (18551): Prevent false positive loop detection on uniform streaming content - #28877
[SSR Agent] Issue Fix (18551): Prevent false positive loop detection on uniform streaming content#28877joneba-google wants to merge 1 commit into
Conversation
…on uniform streaming content $fixes google-gemini#18551 Issue URL: google-gemini#18551 ### Context & Problem The loop detection service previously identified a false-positive loop immediately after a prompt submission when streamed responses contained uniform/padded characters such as consecutive spaces. This occurred because the sliding window step of 1 character allowed adjacent, highly overlapping chunks to be classified as distinct repeating periods. ### Detailed Changes * **Chunk Index Overlap Check**: Updated `packages/core/src/services/loopDetectionService.ts` to require that consecutive occurrences of identical content chunks be separated by a distance of at least `CONTENT_CHUNK_SIZE` (50 characters) to be indexed. This successfully filters out overlapping sub-clones within the sliding window, preventing false positive loops on repetitive uniform content while still perfectly capturing real, non-overlapping loop repetitions. * **Code Block State Tracking Reset**: Resolved a state persistence bug by ensuring that `this.inCodeBlock` is correctly reset to `false` inside the service's `reset()` function. * **Unit Tests**: Added test cases in `packages/core/src/services/loopDetectionService.test.ts` to evaluate streaming content containing 70 consecutive spaces/repetitive characters, asserting they do not trigger a false-positive loop, and to verify correct state tearing down of `inCodeBlock`. ### Verification * Verification check of the modified unit test file `packages/core/src/services/loopDetectionService.test.ts` has been completed successfully via static inspection, confirming that the new cases cover continuous space boundaries and proper service resets.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses false-positive loop detection issues occurring during streaming responses with repetitive content. By enforcing a minimum distance between indexed content chunks and ensuring proper state cleanup, the service now more reliably distinguishes between actual loops and uniform character sequences. These changes improve the robustness of the loop detection logic and ensure consistent behavior across service resets. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
|
📊 PR Size: size/S
|
There was a problem hiding this comment.
Code Review
This pull request updates the 'LoopDetectionService' to prevent false positive loop detections on uniform content (such as consecutive spaces or identical characters) by ensuring that the distance between the current content index and the last recorded index is at least 'CONTENT_CHUNK_SIZE'. Additionally, it ensures that the 'inCodeBlock' state is correctly reset to 'false' when the service is reset. Corresponding unit tests have been added to verify these behaviors. There are no review comments, so I have no feedback to provide.
fixes #18551
Issue URL: #18551
Context & Problem
The loop detection service previously identified a false-positive loop immediately after a prompt submission when streamed responses contained uniform/padded characters such as consecutive spaces. This occurred because the sliding window step of 1 character allowed adjacent, highly overlapping chunks to be classified as distinct repeating periods.
Detailed Changes
packages/core/src/services/loopDetectionService.tsto require that consecutive occurrences of identical content chunks be separated by a distance of at leastCONTENT_CHUNK_SIZE(50 characters) to be indexed. This successfully filters out overlapping sub-clones within the sliding window, preventing false positive loops on repetitive uniform content while still perfectly capturing real, non-overlapping loop repetitions.this.inCodeBlockis correctly reset tofalseinside the service'sreset()function.packages/core/src/services/loopDetectionService.test.tsto evaluate streaming content containing 70 consecutive spaces/repetitive characters, asserting they do not trigger a false-positive loop, and to verify correct state tearing down ofinCodeBlock.Verification
packages/core/src/services/loopDetectionService.test.tshas been completed successfully via static inspection, confirming that the new cases cover continuous space boundaries and proper service resets.