Case study

The Loop That Cost Twenty-Two Thousand

This is an illustrative scenario, not a report of a specific incident. No real company is described. The figures are indicative of the failure class, not measured outcomes.

The situation

A small business automated bulk document processing with a script that called a commercial AI API. It worked on the first thousand documents.

What went wrong

One document was malformed in a way the script had not anticipated. The agent did what agents do with an error: it retried. It kept retrying, because nothing told it to stop and nothing metered the cost. It ran for around twelve hours before a person noticed a billing alert.

The mechanism worth understanding

An agent loop with no exit condition and no cost ceiling is not a bug. It is an unfinished design.

The failure is unremarkable, which is what makes it worth studying. There was no attacker, no vulnerability, no malicious intent. There was an error handler that treated a permanent failure as a temporary one, and a billing model that charges per attempt.

This is the most common way AI costs a small business money: not through a breach, but through a loop nobody bounded.

What actually prevents this

  • Maximum retry counts on every call, set low, with an alert when reached.
  • Hard platform-level spending caps — not dashboards, caps. A dashboard is a notification; a cap is a stop.
  • Backoff with a retry ceiling so a permanent error fails fast instead of burning budget.
  • Dead-letter handling: after N failures, park the item and move on.
  • A daily spend alert that a human actually receives. Alerts to an inbox nobody reads are not controls.

What it costs when it happens

Unbounded loops on commercial APIs have cost small businesses sums ranging from a few hundred euros to five figures over a single weekend. Indicative, not measured.

The question to ask this week

Open your AI provider's billing console and check whether a hard cap is set. If the answer is "we monitor it", you do not have a cap. You have a habit of looking.