Home / Articles

Containment Engineering: Why AI Agent Costs Are Spiking

Microsoft and Uber hit cost walls with AI agents. Why they burn tokens so fast, and four containment tactics: routing, budget tripwires, pruning, oversight.

Publisher: REACTAPP.TOP6 min read1382 words

This article is published in English.

Sources: Why Microsoft and Uber Are Pulling the Plug on AI Agents

Two years of headlines said the same thing: engineers cost a lot, AI agents cost little, and a digital worker that never sleeps or complains for a fraction of a salary would make replacement inevitable. Lately, in the planning meetings of some very tech-forward companies, the spreadsheet has started contradicting that story.

Two companies, two wake-up calls

Microsoft opened Claude Code to its internal engineering teams in late 2025. It was deeply wired into daily workflows and developers liked it. By mid-2026 the company was withdrawing those licenses and steering people toward cheaper in-house options such as GitHub Copilot CLI.

Uber's case was sharper. In April 2026 its CTO admitted that the entire 2026 budget for AI coding tools was gone after only four months. Adoption had reached 84% of engineers, usage had turned into a company-wide leaderboard game, and one engineering leader burned through $1,200 in tokens during a single two-hour demo.

The AI never stopped working. It just got unsustainably expensive. For anyone building agentic systems, the news matches a ceiling that's easy to hit: the compute bill for an autonomous digital worker can climb past the salary of the person it was meant to replace.

The way out is a discipline that's about to become mandatory, called Containment Engineering.

Why agents cost so much more than chat

A chat prompt and an autonomous agent are different animals. Ask a standard language model a question and the meter ticks once: you ask, it answers, the transaction is done.

An agent takes an open-ended goal instead. Told to fix a bug, it reads files, drafts a plan, writes an edit, runs tests and evaluates its own result. A failing test restarts the loop, so it rethinks, rewrites and tests again. Every step is billed.

Real software work makes this a serious financial exposure. SWE-bench is a standard industry test assembled from bugs in actual production code, and the best agents available now solve fewer than half of its tasks. For over half the bugs, then, the agent tries, fails, retries, fails again and finally gives up.

Picture a plumber who charges the full hourly rate whenever he drops his wrench, bills for every walk to the van and leaves with the pipe still dripping. At enterprise scale, a failed agent task is that plumber. The dropped wrench gets paid for in full.

Token consumption doesn't merely double against a chat window. On average an agent uses 5 to 30 times more, and a runaway agent in a hard debugging scenario can spike beyond 1,000 times the price of an ordinary prompt.

Two cost curves that diverge

Human economics and AI economics follow different curves. As a junior developer improves, output rises while pay stays roughly flat through that stretch. They just get faster and more efficient.

An agent facing a hard problem needs far more reasoning steps, retries and context-window use, so the token bill shoots up. The harder the problem, the steeper the cost.

Hardware gains don't rescue the situation, because software demand outruns the savings. Microsoft's Maia 200 chips, now running in its data centers, deliver clearly better tokens per dollar than older hardware. Yet the agent workloads stacked on top absorb all of that saving at once. Cheaper tokens just mean agents ask for exponentially more of them.

So the idea of releasing an agent onto a whole enterprise codebase and leaving it alone is finished, because the math doesn't hold. Agents aren't useless, though. The architecture around them has to change, and quickly.

Containment Engineering

For anyone building AI applications, prompt engineering is no longer the only job. The job is Containment Engineering: hard boundaries, state limits and financial tripwires wrapped around the models, so the machine proves its value before it builds up a bill.

The concern is concrete. Picture an inventory management system on Next.js 16, TypeScript and Azure OpenAI. Latency and hallucinations hardly matter there compared with the fear of an autonomous agent trapped in a reasoning loop, draining cloud credits overnight. A similar worry applies to a genomic processing job on the Modal platform that scores thousands of ClinVar reference sequences and hits a hard execution timeout at exactly two hours. That was ordinary compute billed per second. A recursive agent billed per token in the same position would have run up a fortune.

Four practices make containment practical.

1. Route requests by difficulty

The commonest mistake is aiming every API call at a flagship model such as GPT-5 or Claude 4.5 Opus. That's brute force, and it burns runway quickly. A routing layer should sit at the very front of the stack instead. A router is a light, extremely cheap model that inspects each incoming task and decides which LLM is actually qualified to handle it.

[ Incoming User Request ]
           |
      [ Router ]
      /        \
[ Simple ]  [ Complex ]
      |          |
[ Llama 3 ] [ Flagship LLM ]

Simple data extraction or basic formatting goes to an open-source 8B model or a tuned mini-model. Work needing deep logic escalates to the expensive flagship. That single change can cut API spend by as much as 80% with no visible drop in application quality.

2. Never allow an unbounded retry loop

An agent allowed to write code, test it and retry on failure needs a hardcoded retry cap. A plain integer isn't enough, though, because context grows with each attempt. The third try costs notably more than the first, since the prompt now carries the memory of two earlier failures.

Add a budget tripwire. Before the agent starts the next recursive step, a middleware function estimates the incoming request's token cost. If the session's running total passes a firm, predefined limit, the process is killed at once and flagged for a human developer to examine.

3. Prune the context

After a failed attempt, an agent usually appends the raw error log to its earlier prompt and goes again. That's where the exponential cost curve comes from. Context pruning counters it. Rather than passing the whole verbose failure history to the flagship model, the cheap router model condenses the failure state.

Feed the giant error log to the inexpensive model with an instruction like "Extract the exact technical reason for this failure in two short sentences." Only those two sentences go back to the main agent for its next try. The context window is pruned deliberately, so token count grows linearly and not exponentially.

4. Keep a human as the kill switch

Having a human in the loop was long treated as a temporary safety feature. It's now a strict financial requirement. A developer's role is becoming watching the agent and catching it the instant it slides into an expensive failure state: checking output, confirming technical direction and halting a runaway process before it bankrupts the sprint budget.

What the shift means

Duolingo recently softened its public position on AI replacing workers. Along with Microsoft and Uber, it ran into a basic fact: humans are the cheapest thinking engines available. A developer's flexible mind runs on a sandwich and a decent night's sleep, and never bills the company a thousand times over just to stop and think.

The bubble of infinite, cheap agents was popped by a plain spreadsheet. For developers just entering the industry, that's reassuring, since roles stay secure while daily responsibilities change. Work moves from hand-writing every line toward designing and containing the systems that write it.

The practical advice is short. Put strict routers into AI stacks, apply aggressive containment to agents and treat the token budget with the same respect as the memory heap. Software engineering's future belongs to people who can control the machine, contain its cost and pull the plug when it drops the wrench.