OpenClaw

OpenClaw agent stuck in a loop

An agent loops when a weaker model keeps re-issuing the same tool call instead of progressing, usually from poor tool-calling reasoning, and every retry burns tokens. Stop the runaway agent first, switch to a stronger tool-calling model, turn on tools.loopDetection.enabled (off by default), cap each run with agents.defaults.timeoutSeconds, set a provider spend limit, and tighten the system prompt.

Likely cause

A weaker model keeps re-issuing the same tool call instead of progressing, usually from poor tool-calling reasoning or no step cap on the agent.

The fix

  1. 1 Stop the runaway agent, then switch to a stronger tool-calling model.
  2. 2 Turn on tool-loop detection with tools.loopDetection.enabled: true (it is off by default), cap each run with agents.defaults.timeoutSeconds, and set a spend limit in your provider dashboard. OpenClaw has no maxIterations setting.
  3. 3 Tighten the system prompt so the goal is unambiguous.
docker restart openclaw
Full guideOpenClaw Agent Stuck in Loop: How to Stop It

Hit a different error?

Paste any agent error and get the cause and fix in seconds.

Open the decoder

Frequently asked questions

How do I stop a loop that's running right now?

Kill the process immediately rather than waiting for it to finish, since every second costs money. Use docker restart openclaw (or docker stop), then check your provider's usage dashboard to assess the damage before restarting with guardrails.

How expensive can a loop actually get?

A single stuck loop can burn $5-50+ per hour. One documented case hit $350 in 3.5 hours over 800+ consecutive turns. Without loop detection, a run timeout or a provider spend limit, an overnight loop can consume your monthly budget.

Is this a bug, or expected agent behavior?

It's largely expected. Agents run a reason-act-observe cycle and will retry persistently when tool feedback is ambiguous. OpenClaw ships rolling tool-loop detection but leaves it off by default, and it has no built-in cost cap, so turn on tools.loopDetection.enabled, set agents.defaults.timeoutSeconds, and add a spend limit at your provider.

Stop firefighting agent errors

Decoding errors one at a time is the manual version of what BetterClaw automates. Run your agents on a no-code AI agent platform with managed models, retries and config validation built in.

Free plan available · Pro $49/mo · BYOK · 7-day money-back guarantee