@@ -38,6 +38,7 @@ describe('LoopDetectionService', () => {
3838 mockConfig = {
3939 getTelemetryEnabled : ( ) => true ,
4040 isInteractive : ( ) => false ,
41+ getDisableLoopDetection : ( ) => false ,
4142 getModelAvailabilityService : vi
4243 . fn ( )
4344 . mockReturnValue ( createAvailabilityServiceMock ( ) ) ,
@@ -162,6 +163,15 @@ describe('LoopDetectionService', () => {
162163 // Should now return false even though a loop was previously detected
163164 expect ( service . addAndCheck ( event ) ) . toBe ( false ) ;
164165 } ) ;
166+
167+ it ( 'should skip loop detection if disabled in config' , ( ) => {
168+ vi . spyOn ( mockConfig , 'getDisableLoopDetection' ) . mockReturnValue ( true ) ;
169+ const event = createToolCallRequestEvent ( 'testTool' , { param : 'value' } ) ;
170+ for ( let i = 0 ; i < TOOL_CALL_LOOP_THRESHOLD + 2 ; i ++ ) {
171+ expect ( service . addAndCheck ( event ) ) . toBe ( false ) ;
172+ }
173+ expect ( loggers . logLoopDetected ) . not . toHaveBeenCalled ( ) ;
174+ } ) ;
165175 } ) ;
166176
167177 describe ( 'Content Loop Detection' , ( ) => {
@@ -742,6 +752,7 @@ describe('LoopDetectionService LLM Checks', () => {
742752 mockConfig = {
743753 getGeminiClient : ( ) => mockGeminiClient ,
744754 getBaseLlmClient : ( ) => mockBaseLlmClient ,
755+ getDisableLoopDetection : ( ) => false ,
745756 getDebugMode : ( ) => false ,
746757 getTelemetryEnabled : ( ) => true ,
747758 getModel : vi . fn ( ) . mockReturnValue ( 'cognitive-loop-v1' ) ,
0 commit comments