Track and remediate model chanting behavior (repeats the same response)
What problem does this solve?
The model sometimes "chants," repeating the same response continuously before eventually hitting the output token limit. . This issue will stop this behavior, improving UX and successful task completion rates.
How will it work?
We'll add detection for repetitive output patterns and work towards encouraging the model to provide a more productive response.
Note: This is different than the #3929 loop issue where the model is unable to identify the next step to take.
Happened with me too
Look here, seems important, the easy way out: https://github.com/sugyan/claude-code-webui/issues/188#issue-3228633164 and https://github.com/google-gemini/gemini-cli/discussions/2841#discussioncomment-13751702
Very interim "adaptation plan" that Gemini itself (Flash!) came up with and is working on now attached, for what it is worth.
This error happens alot
x replace {"new_string":"","file_path":"/Users/.......<file-path>......
Failed to edit, 0 occurrences found for old_string in /Users/.......<file-path>.... No edits made. The exact text in old_string was not found. Ensure you're not escaping content incorrectly and check whitespace, indentation, and context. Use read_file tool to verify.
x replace {"new_string":"","file_path":"/Users/.......<file-path>......
Failed to edit, 0 occurrences found for old_string in /Users/.......<file-path>.... No edits made. The exact text in old_string was not found. Ensure you're not escaping content incorrectly and check whitespace, indentation, and context. Use read_file tool to verify.
x replace {"new_string":"","file_path":"/Users/.......<file-path>......
Failed to edit, 0 occurrences found for old_string in /Users/.......<file-path>.... No edits made. The exact text in old_string was not found. Ensure you're not escaping content incorrectly and check whitespace, indentation, and context. Use read_file tool to verify.
and then finally the dreaded loop error
ℹ A potential loop was detected. This can happen due to repetitive tool calls or other model behavior. The request has been halted.
Me too. Cannot use the tool :( very upsetting, any workarounds
I have the same issue too. qwen-cli with qwen-coder never have such issue.
Loved gemini-cli, but it has become unusable. Every conversation immediately goes into a "nynynyny" loop even with a simple "hi." I deleted my GEMINI.md and even did a clean install of the tool, and the problem persists.
It's only this frustrating because it is such a good tool when it works.
I got it working by rolling back to version 0.1.15 using npm install -g @google/[email protected].
Any version after that goes into the deathloop again.
Rolling back to 0.1.17 fixed the problem for me. npm install -g @google/[email protected]
I notice that this problem appears when replacetool is used. writetool is one way to escape. So many tokens are being wasted and the we have to pay for nothing getting done.
I haven't had that problem - I guess it's a feature and not a bug 😉
Ever tried to notice differences in wording or the melody of the voice? Are U guys sure it's repetitive?
Happens to me when running /init on an existing project:
potential loop was detected. This can happen due to repetitive tool calls or other model behavior. The request has been halted.
Not very user-freindly.
We have loop detection, added an internal fix to reduce this to a very small number of requests. Closing this since there is no more AIs.
I'm curious about the features used for detection. I didn't use the Gemini CLI directly, but rather the Gemini 2.5 Pro model on the Google Cloud Platform. I often encounter questions where I answer the same questions repeatedly.
I hope to refer to your solution to fix this problem. I would be very grateful if anyone could share the relevant diffs.
Why was this issue closed? it happens for me all the time still. Maybe more frequently last week.
What did it for me at least was:
- gemini --list-sessions
- gemini --delete-session
I deleted all sessions.
I got tired of waiting for an official fix for the duplicated ending sentences in Gemini CLI (especially noticeable when using voice output), so I built a lightweight Windows PowerShell workaround that filters out the duplicated text in real time and adds native neural voice output (English & Czech) with zero repetition.
Everything is free, clean, and ready to use here: 👉 https://github.com/Puskvorec/gemini-cli-voice-fix