Commit graph

1 commit

Author SHA1 Message Date
Roo Code
c9b1d5e1cf fix: detect and abort repetitive reasoning loops in model thinking output
Adds a ReasoningRepetitionDetector that monitors streaming reasoning/thinking
content for repetitive patterns. When a line is repeated more than a threshold
number of times (default 5), the stream is aborted early to save tokens and
the model receives guidance to try a different approach.

This addresses an issue where some models (particularly Gemini) get stuck in
reasoning loops, repeating the same lines like "I'll use attempt_completion"
or "I'll mention that I verified with tests" indefinitely.

Changes:
- New ReasoningRepetitionDetector class with streaming chunk support
- Integration into Task.ts reasoning streaming handler
- New reasoningRepetitionDetected response format for model guidance
- 18 unit tests covering detection, normalization, reset, and edge cases

Closes #11337
2026-02-09 18:43:16 +00:00