mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 22:21:22 -07:00
fix(core): ensure loop detection respects session disable flag (#12347)
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