Home / Glossary / What is a runaway agent loop?
What is a runaway agent loop?
A runaway agent loop is when an autonomous AI agent repeats actions — often the same tool call with identical arguments — without ever reaching its stopping condition. Because each step makes a paid LLM call, the loop quietly accumulates cost until something external stops it.
Runaway loops are the most expensive failure mode of autonomous agents because they fail quietly. A documented LangChain case ran four agents in a loop for 11 days and cost $47,000 before anyone noticed.
Common shapes
- The same tool called thousands of times with identical arguments.
- A reasoning loop that never satisfies its stop condition.
- A planner that fans one task out into ever more subagent calls.
How to prevent one
Put a hard, per-run limit in the agent process: detect identical-call repeats, cap total steps and tool calls, set a wall-clock ceiling, and enforce a maximum spend per run. AgentBrake does exactly this in one line.
Related
Stop your next runaway agent
One line of code. Open source. Works on LangChain 1.x, CrewAI 1.x, and the classic AgentExecutor.
$
Star on GitHub
pip install agentbrake-sdk
Frequently asked questions
- How do you stop a runaway agent loop?
- Detect identical repeated calls and enforce hard per-run limits (cost, steps, tool calls, duration) in-process, so the run halts before the next call. A tool like AgentBrake adds this in one line.
- Why are runaway loops so expensive?
- Each loop iteration is a paid LLM call, and the failure is silent — there's no crash, so the run can continue for hours or days before anyone notices.