fix(core): remove LLM-based loop detection and enable skipLoopDetection by default#2092
Merged
Merged
Conversation
…on by default The LLM-based loop detection was causing issues where the process would stop unexpectedly. This change removes the LLM-based loop detection feature entirely and sets skipLoopDetection to true by default to prevent false positives from interrupting user sessions. Co-authored-by: Qwen-Coder <[email protected]>
tanzhenxin
requested review from
DennisYu07,
LaZzyMan,
Mingholy,
gwinthis and
pomelo-nwu
as code owners
March 4, 2026 15:21
Contributor
📋 Review SummaryThis PR removes the LLM-based loop detection feature and changes the default value of 🔍 General Feedback
✅ Highlights
|
Contributor
Code Coverage Summary
CLI Package - Full Text ReportCore Package - Full Text ReportFor detailed HTML reports, please see the 'coverage-reports-22.x-ubuntu-latest' artifact from the main CI run. |
xaelistic
pushed a commit
to xaelistic/qwen-code
that referenced
this pull request
Jun 7, 2026
…tion fix(core): remove LLM-based loop detection and enable skipLoopDetection by default
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TLDR
Removes the LLM-based loop detection feature and changes the default value of
skipLoopDetectionfromfalsetotrue. This fixes issues where the loop detection was incorrectly triggering and stopping the process unexpectedly.Dive Deeper
Why this change?
Modern models are proficient at tool use: The LLM-based loop detection was generating more false positives than true negatives. Modern models are capable of handling complex tool use scenarios without getting stuck in loops, making this detection mechanism more harmful than helpful.
LLM-based loop detection breaks cache continuation: The LLM-based check adds extra API calls that can interfere with caching mechanisms, reducing efficiency and potentially causing unexpected behavior.
Trust the LLM: We should trust that the LLM can manage its own workflow. The simple heuristic-based checks (consecutive identical tool calls, chanting identical sentences) are sufficient to catch obvious loops without the overhead and false positives of LLM-based detection.
What was removed?
turnStartedmethod and all LLM-based loop detection logic fromLoopDetectionServiceturnStartedinGeminiClientLLM_DETECTED_LOOPenum value fromLoopTypeskipLoopDetectionchanged totruein both config and settings schemaWhat remains?
The streaming-based heuristic loop detection remains in place:
These simple heuristics are sufficient for catching obvious loops without the overhead and false positives of LLM-based detection.
Reviewer Test Plan
cd packages/core && npx vitest run src/services/loopDetectionService.test.ts && cd ../cli && npx vitest run src/config/config.test.tsTesting Matrix
Linked issues / bugs
Fixes #2038
🤖 Generated with Qwen Code