feat(core): add setting to disable loop detection (#18008)

This commit is contained in:
Sandy Tao
2026-02-02 10:13:20 -08:00
committed by GitHub
parent b0be1f1689
commit e860f517c0
9 changed files with 46 additions and 2 deletions

View File

@@ -38,6 +38,7 @@ describe('LoopDetectionService', () => {
mockConfig = {
getTelemetryEnabled: () => true,
isInteractive: () => false,
getDisableLoopDetection: () => false,
getModelAvailabilityService: vi
.fn()
.mockReturnValue(createAvailabilityServiceMock()),
@@ -162,6 +163,15 @@ describe('LoopDetectionService', () => {
// Should now return false even though a loop was previously detected
expect(service.addAndCheck(event)).toBe(false);
});
it('should skip loop detection if disabled in config', () => {
vi.spyOn(mockConfig, 'getDisableLoopDetection').mockReturnValue(true);
const event = createToolCallRequestEvent('testTool', { param: 'value' });
for (let i = 0; i < TOOL_CALL_LOOP_THRESHOLD + 2; i++) {
expect(service.addAndCheck(event)).toBe(false);
}
expect(loggers.logLoopDetected).not.toHaveBeenCalled();
});
});
describe('Content Loop Detection', () => {
@@ -742,6 +752,7 @@ describe('LoopDetectionService LLM Checks', () => {
mockConfig = {
getGeminiClient: () => mockGeminiClient,
getBaseLlmClient: () => mockBaseLlmClient,
getDisableLoopDetection: () => false,
getDebugMode: () => false,
getTelemetryEnabled: () => true,
getModel: vi.fn().mockReturnValue('cognitive-loop-v1'),