Skip to main content
← Back to Currents

5 Ways Sloppy Code Inflates Your AI Bill

September 2, 2026

AI ImplementationAI StrategyAgentic Coding
The character feeds a slim folder into a coin-slot AI reading machine while a tangled paper ball needs a tall stack of coins instead

Token-metered agents just put a real price tag on something that used to be a faith argument: is messy code actually worth cleaning up? Here's what we watch for when a client's AI bill is bigger than the work should cost.

Every extra line an agent has to read gets billed, every time it touches that file. Thoughtworks' Giles Edwards-Alexander ran the experiment: refactoring one 17,155-line Rust file into smaller modules cut the input tokens for an identical follow-up change from 159,564 to 27,360, an 83 percent drop, because the agent only had to read the relevant file instead of the whole thing. Messy code doesn't just cost more to change by hand. It costs more every single time an agent reads it too, and that cost repeats on every future change.

Wide permissions plus no spend cap is how a routine task turns catastrophic. Amazon spent $1.8 million on a Claude Sonnet task matching author names to product listings, 860 percent over budget, and nobody caught it for five months. Two smaller projects ran $541,000 and $134,000 over the same way. None of these were exotic failures. They were ordinary tasks nobody was watching.

Output tokens cost more than input tokens, so a chatty agent adds up fast. Edwards-Alexander's data showed output barely moved even as input dropped, and those tokens run several times pricier. Code that forces an agent into long explanations, repeated fix-it-again loops, or bloated generated output is paying the expensive rate more often, not the cheap one.

Duplication isn't just a maintenance headache, it's a rereading tax. An agent working across code with the same logic copied six places has to load all six just to reason about a change safely. We check for this the same way we'd check it in any legacy estate, because the fix and the payoff are the same.

No real-time cost visibility means the surprise shows up after the money's already spent. One of Amazon's own engineers put it bluntly: "it's difficult to figure out how much anything costs." That's a tooling gap, not an AI problem, and you can check for it before a project starts, not after the invoice does.

None of this argues against agentic delivery. It argues for treating a codebase's cleanliness as a cost input, not just a quality one. Our implementation reviews include this math before a client signs off on scope. AI that ships, not AI that demos.

Have a problem worth solving?

Tell us what you are trying to build or modernize, and we will tell you honestly how we would approach it.