mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-13 15:40:57 -07:00
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:
@@ -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', () => {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user