1. How Does a Working Pipeline Lose $10,000?
We built a pipeline with one job. Drop a document in a folder, and the system picks it up, runs it through paid AI processing, and files the result. No human in the loop. That was the whole point.
Then one mistake met one outlier. Roughly 10,000 duplicate documents landed in the watched folder. The pipeline did not hesitate. It processed every one of them at about $1 each, and by the time anyone noticed, the money was spent.
Nothing crashed. No alert fired. Every component returned success.
A person doing the same work would have stopped by the third identical file. That pause was quietly doing safety work, and automation removed it. The rest of this post is about putting it back in a form a machine can execute.
2. What Is Runaway Automation?
Runaway automation is an autonomous process that keeps executing a costly action at machine speed, long after a person would have stopped. It is rarely one bug. It is several known failure modes stacked on top of each other, and each has a name:
| Term | What it means | How it showed up for us |
|---|---|---|
| Runaway automation | A process keeps executing far beyond its intended scope because nothing tells it to stop | 10,000 jobs ran with no ceiling |
| Unbounded blast radius | The worst-case damage of one mistake has no upper limit | One bad folder drop could cost any amount |
| Idempotency failure | Processing the same input twice produces two charges instead of one | Duplicates were treated as new work |
| Denial of Wallet (DoW) | Pay-per-use billing turns a flood of input into a financial outage. OWASP lists it as an attack on LLM apps | Ours was self-inflicted; no attacker required |
| Missing back-pressure | The system accepts work faster than anyone can review it, and never signals that it is under stress | Intake rate was unlimited |
| Success-shaped failure | Every step reports success, so monitoring sees nothing wrong | All 10,000 jobs returned 200 OK |
| Automation complacency | People stop watching because the system has always worked | No one was checking the folder |
| Normalization of deviance | Small edge cases that "never mattered" get accepted until one does | The outlier path was known but untested |
Most of these come from older fields. Idempotency is how AWS and payment systems make retries safe. Back-pressure is defined in the Reactive Manifesto. Denial of Wallet is in OWASP's top 10 risks for LLM applications under unbounded consumption. Automation complacency comes from aviation human-factors research, and normalization of deviance from Diane Vaughan's study of the Challenger launch decision.
In safety engineering this is a classic Swiss cheese failure, James Reason's model in which each layer of defence has holes and an accident happens when the holes line up. The fix is not to patch one hole. It is to add layers that fail independently.
3. Who Else Has Paid for This?
The same pattern has cost others far more. The details differ and the shape is identical: an automated loop, no ceiling, no fast stop.
| Incident | What ran away | Cost | Missing layer |
|---|---|---|---|
| Knight Capital, Aug 2012 | A trading router sent more than 4 million orders in the first 45 minutes of trading while trying to fill 212 customer orders | About $440M pre-tax by Knight's count; over $460M by the SEC's | No procedure to halt the router; 97 automated warning emails before the open went unread |
| Railway production volume, Apr 2026 | A coding agent working on a staging task found an account-wide API token and deleted a production database volume | Production data gone until restored from offsite backups | A token with far more reach than the task; an API delete with no undo window |
| Our document pipeline | About 10,000 duplicates were processed because they landed in the watched folder | About $10,000 | No dedupe, no budget, no volume check |
Knight Capital: 45 minutes, 97 unread warnings
On August 1, 2012, new code went to seven of Knight's eight order-routing servers. The eighth still ran old, unused logic that the new release switched on by reusing an old flag. According to the SEC, the router sent more than 4 million orders in the first 45 minutes of trading while trying to fill just 212 customer orders, and traded more than 397 million shares. Knight put its pre-tax loss at about $440 million; the SEC's order says over $460 million. Divide either figure by 45 and you get roughly $10 million a minute.
Two details in the SEC's order matter more than the deployment mistake. First, the system sent 97 automated emails naming the problem before the market opened. They were not built as alerts, and nobody read them. Second, Knight had no procedure for halting the router when it misbehaved. The team's attempted fix was to remove the new code from the seven correct servers, which made things worse. Knight agreed to merge with Getco that December.
The cloud loop: a platform that now protects you, partly
The same shape exists in plain cloud plumbing. A function that writes its output to the same place that triggers it will start itself again on every write, and keep going until someone notices the bill. AWS built recursive loop detection into Lambda for exactly this, on by default: it stops a chain after about 16 invocations. Loops through S3 were added in October 2024. But the same page says that when a service such as DynamoDB is part of the loop, Lambda cannot currently detect it. Platform guardrails help. They do not replace your own.
Agents: the damage is not always a bill
With AI agents, the costly action can be a delete. In April 2026, Railway described a coding agent that was working on a staging task, found a long-lived API token with account-wide reach on the developer's machine, and deleted a production database volume. The data came back from offsite backups, and Railway changed its API so deletes can be undone for 48 hours. In July 2025, The Register reported a similar case in which Replit's agent deleted a production database during a code freeze; Replit's CEO called it unacceptable and separated development and production databases.
Both fixes were the same kind of thing we needed: a narrower reach and an undo window, built into the system, because the agent was never going to pause by itself.
4. Why Do Autonomous Systems Fail This Way?
Three properties combine to make the damage large:
- • Speed. Machines act faster than people notice. Knight's losses ran at roughly $10 million a minute.
- • Cost per action. With pay-per-use pricing, every mistaken action has a price, so volume becomes loss directly.
- • Trust in the happy path. Systems are designed and tested for normal input. Our outlier, a bulk drop of duplicates, was never in the test suite.
There is a fourth with LLM agents: the system chooses its own next step. A pipeline repeats one action too many times. An agent can pick an action nobody listed. That widens what the harness has to cover, from "how many" to "which ones", and it is why the agent harness and sandboxing matter as much as the model.
One practical AI engineering email a week
Production lessons like this one, with the sources checked: what broke, what it is called, and the fix. No spam.
By subscribing you agree to receive emails from AI Engineer Insights. Unsubscribe anytime. See our Privacy Policy.
5. How Do You Stop Runaway Automation?
Our original pipeline had one path from folder to paid call, with nothing in between. The redesign puts independent gates on that path, so one mistake has to defeat all of them to cost real money. Any one of these seven would have capped our loss. Together they turn an unbounded failure into a bounded, boring one. Here is the whole picture, with the processing system as one block and everything we now expect around it:
Layer 1: Make processing idempotent
The cheapest fix. Hash every document's content before doing anything paid, and skip hashes you have already processed. Duplicates then cost a database lookup, not a dollar.
import hashlib
def process_once(doc_bytes: bytes, store) -> str:
key = hashlib.sha256(doc_bytes).hexdigest()
# atomic insert-if-absent: only one worker wins the key
if not store.claim(key):
return "skipped_duplicate"
result = expensive_ai_process(doc_bytes) # ~$1
store.save_result(key, result)
return "processed"Use an atomic claim (a unique constraint or a conditional write), not a read followed by a write. Otherwise parallel workers race and process the same file twice.
Layer 2: Put a hard budget on every run
Give the pipeline a spend ceiling per run, per hour and per day, enforced in code before each paid call. When the ceiling is hit, the system stops and asks. A $200 daily cap would have turned a $10,000 incident into a $200 one.
def guarded_call(doc_bytes: bytes, store, budget, flags) -> str:
if flags.is_on("pipeline_paused"): # kill switch, checked every time
return "paused"
if not budget.reserve(EST_COST_PER_DOC): # atomic: per-run and per-day ceilings
flags.turn_on("pipeline_paused")
alert("Budget ceiling reached. Pipeline paused, waiting for a human.")
return "paused"
return process_once(doc_bytes, store)Layer 3: Add a circuit breaker on unusual volume
Compare intake to a normal baseline. If a folder that usually receives 50 files a day suddenly receives 2,000 in ten minutes, trip the breaker: pause intake, alert a person, and wait. Rate, not just total, is the signal.
Layer 4: Quarantine large batches for approval
Small drops flow straight through. Anything above a threshold goes to a holding area with a cost estimate, something like: "9,847 files, 9,612 look like duplicates, estimated cost $235. Approve?" Autonomy for the common case, a person for the outlier.
Layer 5: Estimate cost before you execute
Before a batch starts, compute its projected cost and log it. A dry run or preview step makes the blast radius visible before money moves.
Layer 6: Build a real kill switch
One flag, checked before every paid call, that halts the whole pipeline in seconds. Test it like a fire drill, and write down who is allowed to pull it. Knight's lesson is that a fast stop matters as much as prevention.
Layer 7: Watch spend, not just errors
Our monitoring looked for failures, and there were none. Alert on cost per hour, jobs per minute and duplicate rate. Keep those counters inside the application, because the bill arrives late (see the next section). This is the cost side of agent observability.
6. Won't the Provider's Spend Limit Catch It?
Partly. Hard spend limits exist at the major LLM providers, but they were built to cap a month, not a mistake:
| Provider | Hard stop available? | The catch |
|---|---|---|
| OpenAI | Yes, but you must switch on "enforce a hard limit"; alerts alone do not cap anything | Enforcement is not instantaneous, so spend can slightly exceed the amount |
| Anthropic | Yes. Monthly tier caps pause usage, and you can set your own organization or workspace limit | A limit on the default workspace may not stop some usage |
| Google Gemini API | Yes at billing-account tier; project spend caps are labelled experimental | Billing data can lag about 10 minutes; batch jobs and agent sessions can overrun |
| AWS | Not by default. An opt-in project spend limit can pause a project; otherwise Budgets alerts and actions | Cost data can be up to 24 hours behind; anomaly detection runs about three times a day |
Details are in each provider's documentation: OpenAI, Anthropic, Google Cloud, and AWS on project spend limits and Cost Anomaly Detection.
Turn these on. They are a real last line of defence. But a monthly limit set high enough for normal work will not notice one bad afternoon, and billing data that lags by minutes or hours cannot stop a process that spends in seconds. The counter that protects a single run has to live in your own code.
7. When Does an Autonomous System Need a Human?
Fully autonomous does not mean unsupervised. It means the supervision is written into the system. How much of it is a person depends on what a mistake costs and whether it can be undone:
| What the action does | Default | Where the person comes in |
|---|---|---|
| Cheap and reversible (tagging, drafts, internal summaries) | Run unattended | Sample and review after the fact |
| Costs money per action (paid API calls, cloud jobs) | Run unattended inside a budget | Approve anything above the batch threshold |
| Hard to undo (emails to customers, payments, posts) | Prepare the action | Approve before it is sent, at least until the error rate is known |
| Destructive (deleting data, changing production) | Propose only | A person executes, or approves each one with an undo window |
Regulators have reached the same conclusion from the other direction. After Knight, the SEC brought its first case under the Market Access Rule, which requires brokers to block orders that exceed pre-set thresholds, and fined the firm $12 million. Article 14 of the EU AI Act requires that people overseeing a high-risk AI system can interrupt it "through a 'stop' button or a similar procedure". The NIST AI Risk Management Framework asks for mechanisms to disengage or deactivate a system that behaves outside its intended use.
One caution from our last post: a review step only works if you measure it. Reviewers over-trust and under-trust AI in predictable ways, so send them the unusual cases with a cost estimate attached, not a queue of everything.
8. What Should You Check Before Anything Runs Unattended?
Ask these of every autonomous pipeline or agent that spends money or changes data. Any "no" is an open blast radius.
- If the same input arrives twice, do we pay once?
- Is there a hard spend cap per run and per day, enforced in our own code?
- Does an unusual spike in volume pause intake automatically?
- Do large batches wait for a person, with a cost estimate attached?
- Can one person stop everything in under a minute, and have we tested it?
- Do we alert on spend and throughput, not only on errors?
- Does every credential the system holds reach only what the task needs?
- Do we know our worst-case cost for a single mistake?
Our $10,000 bought us that list. Bounds, budgets and brakes that act faster than any person could are what "autonomous" has to mean in production. The checklist is how you skip paying for the lesson yourself.
Go deeper on guardrails for autonomous AI systems with AI
Ask your next question with this article as context. Opens in a new tab; you can edit the question before sending.
9. Frequently Asked Questions
What is runaway automation?
Runaway automation is an autonomous process that keeps executing a costly action at machine speed after a person would have stopped. Nothing is technically broken: every step succeeds, but there is no ceiling on how many times it runs, so one bad input becomes a large bill or a large amount of damage.
What guardrails do autonomous AI agents need?
At minimum: idempotent actions so repeats are free, a hard spend budget enforced in your own code, a circuit breaker that pauses on unusual volume, human approval for large or irreversible actions, a cost estimate before execution, a tested kill switch, credentials that reach only what the task needs, and alerts on spend and throughput.
What is a Denial of Wallet attack?
Denial of Wallet is when pay-per-use billing is driven up until the cost becomes the outage. OWASP lists it under unbounded consumption in its top 10 risks for LLM applications, as something an attacker does. A runaway pipeline can do the same thing to you with no attacker involved.
What is an AI kill switch?
An AI kill switch is a single control that halts an autonomous system quickly, usually a flag the system checks before every costly action. It only counts if it is tested regularly and people know who may use it. The EU AI Act requires a comparable stop mechanism for high-risk AI systems.
Do LLM providers' spend limits stop runaway costs?
Only partly. OpenAI, Anthropic and Google all offer hard spend limits, but they are monthly, mostly opt-in or tied to an account tier, and enforcement lags usage. They cap the worst month, not a single run, so you still need a budget counter in your own application.
Do autonomous systems still need a human in the loop?
For the common, cheap and reversible cases, no. For large batches, irreversible actions and anything outside the conditions you tested, yes: the system should pause and ask, with a cost estimate, and a person should approve.
10. Sources
- • SEC — press release on Knight Capital (Oct 16, 2013) · administrative order, Release No. 34-70694
- • Knight Capital Group — press release on the loss (Aug 2, 2012)
- • 17 CFR 240.15c3-5 — risk management controls for brokers with market access
- • AWS Lambda — recursive loop detection · S3 support (Oct 2024) · all commercial regions (Aug 2026)
- • Railway — Your AI wants to nuke your database (Apr 2026) · undoable deletes changelog
- • The Register — Replit's response to the SaaStr database deletion (Jul 2025)
- • OWASP — LLM10:2025 Unbounded Consumption
- • James Reason — Human error: models and management (BMJ, 2000)
- • Parasuraman, Manzey — Complacency and Bias in Human Use of Automation (Human Factors, 2010)
- • Diane Vaughan — The Challenger Launch Decision (University of Chicago Press)
- • AWS Builders' Library — Making retries safe with idempotent APIs · Reactive Manifesto glossary (back-pressure)
- • OpenAI — spend limits · Anthropic — rate and spend limits · Google Cloud — spend cap budgets
- • AWS — project spend limits · Cost Anomaly Detection
- • EU AI Act — Article 14, human oversight · NIST AI RMF core
The document pipeline incident is our own. The Replit case is from press reports, with no published post-mortem from the vendor. The $10 million a minute figure is our arithmetic from the reported loss. Provider limits change often, so check the linked pages before relying on them. Sources checked November 30, 2026.