gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

Track and remediate model chanting behavior (repeats the same response)

Open anj-s opened this issue 1 year ago • 17 comments

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.

anj-s avatar Jul 11 '25 23:07 anj-s

Happened with me too

benmordecai avatar Jul 12 '25 00:07 benmordecai

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.

GEMINI_ADAPTATION_PLAN.md

Manamama avatar Jul 14 '25 15:07 Manamama

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.

lohriialo avatar Aug 07 '25 13:08 lohriialo

Me too. Cannot use the tool :( very upsetting, any workarounds

multib0t avatar Aug 07 '25 21:08 multib0t

I have the same issue too. qwen-cli with qwen-coder never have such issue.

dingkwang avatar Aug 07 '25 21:08 dingkwang

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.

ajac-zero avatar Aug 08 '25 20:08 ajac-zero

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.

ajac-zero avatar Aug 08 '25 20:08 ajac-zero

Rolling back to 0.1.17 fixed the problem for me. npm install -g @google/[email protected]

daniellesniak avatar Aug 09 '25 17:08 daniellesniak

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.

gnowgi avatar Aug 10 '25 08:08 gnowgi

I haven't had that problem - I guess it's a feature and not a bug 😉

Rand0MGem-Ini avatar Aug 10 '25 08:08 Rand0MGem-Ini

Ever tried to notice differences in wording or the melody of the voice? Are U guys sure it's repetitive?

Rand0MGem-Ini avatar Aug 10 '25 08:08 Rand0MGem-Ini

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.

Boh1 avatar Aug 25 '25 17:08 Boh1

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.

anj-s avatar Sep 15 '25 17:09 anj-s

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.

pointhalo avatar Sep 28 '25 07:09 pointhalo

Why was this issue closed? it happens for me all the time still. Maybe more frequently last week.

d3ming avatar Dec 31 '25 20:12 d3ming

What did it for me at least was:

  • gemini --list-sessions
  • gemini --delete-session

I deleted all sessions.

teddyteh avatar Jan 01 '26 07:01 teddyteh

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

Puskvorec avatar Nov 26 '26 22:11 Puskvorec