← Lab
Field note·Agentic Systems & Orchestration·4 min read

The Agent Loop of Death

An agent without a termination condition is not an agent. It is a billing machine.

The Agent Loop of Death

The failure is simple and expensive. Agent A sends a request. Agent B asks for clarification. Agent A sends the same request again. Agent B asks again. Neither has any way to notice it is stuck, so the exchange continues until someone looks at the bill.

$847

what an unbounded overnight loop can cost, with zero tasks completed

Left running for six hours, that shape burns through 200,000+ tokens and completes nothing. The root cause is always the same: no agent in the system had a clear termination condition, so the system had no way to know it was failing.

Eight safeguards that prevent it

01Max iterationsA hard cap — around 15 per task. On reaching it, stop and return the partial result.
02Wall-clock timeoutAround 5 minutes, enforced outside the agent's own logic.
03Repeat detectionHash each request. The same call twice is a stop condition, not a retry.
04Token budget per runA ceiling that kills the run, not a warning nobody reads.
05Delegation depth capA worker can never start another orchestrator.
06Progress requirementNo new state after N steps means the run is not progressing.
07Spend alarmAlert on rate of spend, not on the monthly total — the monthly total arrives too late.
08Kill switchOne command halts every run in flight. Test it before you need it.
What to take away
  • Every agent needs a hard iteration cap and a wall-clock timeout.
  • Detect repeats: the same call twice means stuck, not retry.
  • Cap delegation depth so a worker cannot spawn an orchestrator.
  • Alert on rate of spend — the monthly total tells you far too late.

Field notes on building production AI systems — collected, verified and written up so they are useful to anyone working on the same problems.

smoke
“Innovation distinguishes between a leader and a follower.”

Need an AI system that holds up in production? Tell me what breaks today and I'll tell you what I'd build.

Call Me now !

mail

abdelmajidzaddi088@gmail.com

address

Mohammedia, Morocco

phone

+212 695 557 631