@@ -320,6 +320,70 @@ describe("Cline", () => {
320320 expect ( cline . diffStrategy ) . toBeDefined ( )
321321 } )
322322
323+ it ( "should use default consecutiveMistakeLimit when not provided" , ( ) => {
324+ const cline = new Task ( {
325+ provider : mockProvider ,
326+ apiConfiguration : mockApiConfig ,
327+ task : "test task" ,
328+ startTask : false ,
329+ } )
330+
331+ expect ( cline . consecutiveMistakeLimit ) . toBe ( 3 )
332+ } )
333+
334+ it ( "should respect provided consecutiveMistakeLimit" , ( ) => {
335+ const cline = new Task ( {
336+ provider : mockProvider ,
337+ apiConfiguration : mockApiConfig ,
338+ consecutiveMistakeLimit : 5 ,
339+ task : "test task" ,
340+ startTask : false ,
341+ } )
342+
343+ expect ( cline . consecutiveMistakeLimit ) . toBe ( 5 )
344+ } )
345+
346+ it ( "should keep consecutiveMistakeLimit of 0 as 0 for unlimited" , ( ) => {
347+ const cline = new Task ( {
348+ provider : mockProvider ,
349+ apiConfiguration : mockApiConfig ,
350+ consecutiveMistakeLimit : 0 ,
351+ task : "test task" ,
352+ startTask : false ,
353+ } )
354+
355+ expect ( cline . consecutiveMistakeLimit ) . toBe ( 0 )
356+ } )
357+
358+ it ( "should pass 0 to ToolRepetitionDetector for unlimited mode" , ( ) => {
359+ const cline = new Task ( {
360+ provider : mockProvider ,
361+ apiConfiguration : mockApiConfig ,
362+ consecutiveMistakeLimit : 0 ,
363+ task : "test task" ,
364+ startTask : false ,
365+ } )
366+
367+ // The toolRepetitionDetector should be initialized with 0 for unlimited mode
368+ expect ( cline . toolRepetitionDetector ) . toBeDefined ( )
369+ // Verify the limit remains as 0
370+ expect ( cline . consecutiveMistakeLimit ) . toBe ( 0 )
371+ } )
372+
373+ it ( "should pass consecutiveMistakeLimit to ToolRepetitionDetector" , ( ) => {
374+ const cline = new Task ( {
375+ provider : mockProvider ,
376+ apiConfiguration : mockApiConfig ,
377+ consecutiveMistakeLimit : 5 ,
378+ task : "test task" ,
379+ startTask : false ,
380+ } )
381+
382+ // The toolRepetitionDetector should be initialized with the same limit
383+ expect ( cline . toolRepetitionDetector ) . toBeDefined ( )
384+ expect ( cline . consecutiveMistakeLimit ) . toBe ( 5 )
385+ } )
386+
323387 it ( "should require either task or historyItem" , ( ) => {
324388 expect ( ( ) => {
325389 new Task ( { provider : mockProvider , apiConfiguration : mockApiConfig } )
0 commit comments