fix(patch): cherry-pick 11e1e98 to release/v0.12.0-preview.7-pr-12347 to patch version v0.12.0-preview.7 and create version 0.12.0-preview.8 (#12383)

Co-authored-by: Sandy Tao <sandytao520@icloud.com>
This commit is contained in:
gemini-cli-robot
2025-10-31 09:31:39 -07:00
committed by GitHub
parent 3d44880ea6
commit cc076e95a8
2 changed files with 18 additions and 1 deletions

View File

@@ -143,6 +143,19 @@ describe('LoopDetectionService', () => {
}
expect(loggers.logLoopDetected).not.toHaveBeenCalled();
});
it('should stop reporting a loop if disabled after detection', () => {
const event = createToolCallRequestEvent('testTool', { param: 'value' });
for (let i = 0; i < TOOL_CALL_LOOP_THRESHOLD; i++) {
service.addAndCheck(event);
}
expect(service.addAndCheck(event)).toBe(true);
service.disableForSession();
// Should now return false even though a loop was previously detected
expect(service.addAndCheck(event)).toBe(false);
});
});
describe('Content Loop Detection', () => {

View File

@@ -123,7 +123,11 @@ export class LoopDetectionService {
* @returns true if a loop is detected, false otherwise
*/
addAndCheck(event: ServerGeminiStreamEvent): boolean {
if (this.loopDetected || this.disabledForSession) {
if (this.disabledForSession) {
return false;
}
if (this.loopDetected) {
return this.loopDetected;
}