A potential loop was detected
The message
A potential loop was detectedWhat it means
Gemini CLI stopped the model because its output looked like it was going in circles: the same tool call over and over, the same text repeating, or a second model judging the session stuck.
What to do
Pick “Keep loop detection enabled” and rephrase the task with a clearer end point. If it's a false alarm, choose “Disable loop detection for this session”, which retries the request.
Gemini CLI pauses mid-task and asks you a question:
? A potential loop was detected
This can happen due to repetitive tool calls or other model behavior. Do you want to keep loop detection enabled or disable it for this session?
Keep loop detection enabled (esc)
Disable loop detection for this session
If you keep it on (Esc does that too), the task ends with the line people search: A potential loop was detected. This can happen due to repetitive tool calls or other model behavior. The request has been halted. In -p mode there's no dialog, just Loop detected, stopping execution. We read the detector in the v0.61.0 source to see what actually trips it.
What counts as a loop
There are three separate checks in loopDetectionService.ts, and any one of them stops the turn.
Repeated tool calls. The same tool with the same arguments five times running is a loop. So is a short repeating pattern, such as read file A, edit file A, read file A, edit file A, up to a cycle of five calls, each repeated five times. This is the check behind most reports of a model re-running the same shell command.
Repeated text. The detector cuts the streamed reply into 50-character chunks and flags it when one chunk shows up 10 times, close together. A model that starts printing the same paragraph again trips this one.
A second opinion from a model. After 30 turns inside a single prompt, Gemini CLI starts asking a model (the code calls its answer the flash result) to read the last 20 turns and rate how likely it is that the session is stuck. It asks every 10 turns by default, sooner when the score is high and later when it's low. A rating of 0.9 or more gets double-checked by a second model before the loop is called. So a halt has nothing to do with running out of room. One commenter on #16295 got it with 94% of the context still free, and that issue was still open on September 26.
What the two choices do
Keep ends the request and leaves detection on. Your conversation is still there, so you can send a new instruction straight away.
Disable turns detection off for the rest of this session only, prints Loop detection has been disabled for this session. Retrying request... and resends your last message as a continuation. If the model really was stuck, it'll carry on being stuck (and spend quota doing it; one April report blames a tool loop for draining a quota).
Stopping it from coming back
For a real loop, the fix is in the prompt. Give the task an end condition the model can check, such as "stop when npm test passes", and break big multi-file jobs into smaller asks so a single prompt doesn't run past 30 turns.
To switch the detector off everywhere, the documented setting is model.disableLoopDetection, a boolean that defaults to false and needs a restart:
{
"model": {
"disableLoopDetection": true
}
}
That goes in ~/.gemini/settings.json for your user, or .gemini/settings.json in a project. Think before doing it in a headless script, where nobody is watching the token count.
Google's own tracker hasn't settled the false-alarm question. #26726, with this exact line, drew a request for reproduction steps and then closed as stale in July 2026. If you hit it on the /about version you're running, a report with the prompt is the most useful thing to attach.
Other lines the same feature prints
Match yours against these if the one at the top of the page is not quite it. They come from the same code and mean related things.
A potential loop was detected. This can happen due to repetitive tool calls or other model behavior. The request has been halted.Loop detected, stopping executionLoop detection has been disabled for this session. Retrying request...Potential Loop Detected