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

Gemini Entered a Loop

Open psytor opened this issue 1 year ago • 0 comments

What happened?

Sorry I know the description will be long, but you need to understand all the steps that it went through.

Using Gemini-CLI inside a project folder, I asked him to make a few modification and then create a Document file based on the changes. But it went too far in the changes so I asked Gemini-CLI to roll back the changes. It started giving errors that it cannot find the line it wanted to delete (I guess it's history knew a line that he supposedly added and wasn't there?)

So it went into a loop for more than 10 times, then looking at the chat history, it broke the loop itself, but started with a similar answer as if I just told it to correct the mistake (mentioned above)... It started the same way and tried to delete the content again.

Then again, it stopped after 2 tries of deleting the lines it couldn't find... And once again it started just as if I asked him to correct the data.

And then it did it again 4 times apologizing for the roll back and will be more careful trying to start the same task AGAIN... But that's not where it got weirder...

I "Cancelled" it's action from that point (whne I saw it was going in a loop) and I tried to prompt him to explained what happened and gave it a chance to correct it self, the answer was weird and might help you:

You are absolutely right, I apologize for getting stuck in that loop. My previous attempts to revert were flawed due to not precisely matching the old_string with the current file content. I understand the frustration this causes.

This "old_string" has nothing to do with my project, so I'm guessing it could be internal.

So it went on devised a plan for the rollback again, tried a few more time this line it could not delete, and then it went on, but everytime it was starting a new file deletion it was apologizing for the misstep in the rollback... And then went on reading an old Document (that was based on my FIRST prompt and nothing to do with the current Rollback)... And then again repeating the same thing constantly and trying to do the roll back...

It finally completed, I asked to make sure the rollback was completely due to it's loop, it went on and found more changes that was not fixed.

Gave it a new task, still related to the same project... Gemini-CLI started to talk about the questions I had... And then it WENT BACK talking about the Rollback AGAIN

I have now completed the rollback of all files to their state right after the V9 cleanup. I have verified backend/main.py, src/utils/workflowEvaluator.js, src/components/ModCard.jsx, and src/config/evaluationWorkflows.js to ensure they are back to their original V9 state.

At first I just thought it was an extra apologies for it's mistake earlier, but then my next prompt which was completely unrelated to the rollback. And it started it's answer with "I am indeed struggling with the rollback..." like if it was answering a questinos I asked before... And believe it or not it actually started working on the rollback AGAIN... Stopped it... Asked if it was ok... Apologiesed etc...

Started a new prompt and it then apologiesed for the rollback agian...

So I just started to ignore his apologies about the Rollback (because it was basically starting every prompt like that)...

What I started to realised, is that it looked like the prompt / answers that I "cancelled" seems to have been kept in memory or somewhere so it was answering to those cancelled prompt even though we pass over them and was not clearing them properly.

What did you expect to happen?

Moving over the loop or cancelled request if I asked so

Client information

 About Gemini CLI                                │
│                                                 │
│ CLI Version     0.1.7                           │
│ Git Commit      55cc809                         │
│ Model           gemini-2.5-flash                │
│ Sandbox         no sandbox                      │
│ OS              linux                           │
│ Auth Method     OAuth 

Login information

Google Account

Anything else we need to know?

No response

psytor avatar Jul 01 '25 06:07 psytor