Guides · Updated October 26, 2026

Cline stuck in a loop: how to stop it, roll back, and cap what it spends

Cline runs on your own API key (or Cline credits), and with auto-approve on it keeps going on its own: read a file, edit, run the tests, read the error, edit again. When the model keeps making the same fix and the same test keeps failing, every turn re-sends the whole conversation and the task cost in the header climbs fast. This guide covers how to stop it now, how to get your code back, how to restart without walking back into the same loop, and the limits that keep the next one small.

The short version

1. What a Cline loop looks like

The common shapes:

Recent versions of Cline have some built-in protection. They watch for repeated identical tool calls and nudge the model to change course, and after a run of consecutive errors the task stops with a message that Cline ran into several errors in a row and asks you for guidance. That catches the obvious cases, like the same failing call over and over. It doesn’t catch a loop where each attempt is slightly different but nothing improves, and it doesn’t put a dollar limit on a task. Older versions had a “max requests” setting in the auto-approve menu; it was removed in v3.35, so don’t rely on finding it.

2. Stop it now

3. Get your code back

With checkpoints enabled, Cline snapshots your workspace as the task goes, in a shadow git repository kept separate from your own. Find a message from before the loop started:

Checkpoints track file changes in the workspace. They don’t undo what commands did outside it: installed packages, database migrations, files written elsewhere, anything pushed. If the loop made git commits, recent versions of Cline refuse to restore a checkpoint older than those commits rather than rewriting your branch. Use git reset or git revert yourself in that case. If checkpoints are turned off in settings, git is your rollback, which is another reason to commit before a long auto-approved task.

4. Restart without walking back into it

Open a new task and give it the facts the loop uncovered:

The test in tests/parser.test.ts fails with "Unexpected token }" at line 42.
Changing the regex in src/parser.ts did not fix it (tried 4 times).
Before editing anything: read src/parser.ts and the test, explain the root cause,
and propose one fix. Don't run the tests more than twice.

5. Limits that keep the next loop small

For unattended runs (the Cline CLI in scripts or CI), also bound wall-clock time with timeout or your CI job’s timeout and give the job its own key with a small limit. More in setting a hard budget for AI coding agents in CI.

Where LoopGuard fits

LoopGuard enforces per-session and daily dollar caps and blocks no-progress repeats through the hook systems of Claude Code, Codex CLI and Cursor. It doesn’t guard Cline today, so for Cline the key-level limit above is the hard stop. If you also use one of those three agents, npm i -g loopguard-cli && loopguard init adds the caps in about a minute, and loopguard report shows what each session spent. The general patterns are in how to stop runaway agent loops.

Related

LoopGuard on GitHub · Pricing