Back to blog
May 4, 2026

Your AI is confidently wrong

It's not the security holes that drain your wallet. It's the loops, the hallucinations, and the rewrites that fix nothing. The failures nobody puts in the demo — and what they actually cost.

It's not the security holes that drain your wallet. It's the loops.

The single most expensive thing in AI-built workflows isn't a security mistake or a bad architecture call — it's the slow drip of tokens spent watching an agent confidently rewrite the same broken code seventeen times in a row, each time more sure it has the answer.

Hallucinations. Loops. Rewrites that fix nothing and break two new things. These are the failures that empty an OpenAI or Anthropic budget over a weekend, and they're not in any tutorial.

This post is about what's actually happening when your AI starts doing this — and how to stop it before the bill.

The four failures that cost the most

1. Hallucinations: confident invention

The model doesn't know what it doesn't know. When it lacks information — about a library version, an API signature, a column in your schema — it fills the gap with something statistically plausible. Not random. Not flagged. Just... made up.

So the AI calls a prisma.user.findManyAndCount() method that doesn't exist. Or imports a function from a package that has a different export. Or writes a SQL query against a column you renamed last week. The code looks right. It compiles. It runs. Sometimes it even seems to work.

Then a user reports that something didn't save, and you spend three hours tracing why.

The model has no internal signal for "I don't know." It generates fluent text either way.

Fix: ground it in real context. Paste actual schema, actual types, actual function signatures. Don't let the AI guess what it could just read.

2. The loop: same fix, fresh confidence

You ask the AI to fix a failing test. It tries. The test still fails. You tell it. It tries something else. Test still fails. You tell it again. It tries the first thing with slight variations.

By call eight, the agent is making confident, articulate, expensive corrections to code that was already correct three iterations ago. Each attempt costs tokens. Each tool call costs tokens. The bill scales linearly with frustration.

The model has no episodic memory of what it tried two minutes ago. Every iteration is fresh.

Fix: stop the loop manually after two failed attempts. Re-read the actual error. Often the AI is chasing a symptom while the cause is elsewhere — a config file, a wrong package version, an outdated mental model of your code. A fresh session with a tighter prompt usually beats six more rounds of the same conversation.

3. Over-broad rewrites

You ask for a one-line change. The AI returns a refactor of three files: renamed variables, shifted formatting, "improved" error handling, and one functional change buried in the middle.

This isn't malicious. It's not even a bug — the model is trained to produce coherent, complete output. Surgical patches are not what it optimizes for.

The bill is twofold: tokens generating the unnecessary rewrites, and the human time spent reviewing changes nobody asked for. The third cost is silent: subtle behavior changes that pass review because the diff was too noisy to read carefully.

Fix: ask for minimal diffs. "Change only line N. Do not modify anything else." Repeat the constraint. If the model still rewrites, that's a signal to use a more disciplined tool — Aider's edit modes, or git-applying a manual patch.

4. Long sessions get dumber

Quality degrades as the chat fills up. Old context, resolved bugs, half-explained constraints, two contradictory things you said an hour ago — all of it weighs on the model's reasoning. Around the 50-message mark the agent starts confusing what's current with what's historical.

You feel it as: "wait, why is it re-implementing the thing we just removed?" Or: "why is it using the old field name?" The session has accumulated noise.

Fix: when an agent gets confused, start a fresh session. Paste the current state of the relevant files. The 30 seconds of re-priming cost less than another 20 messages of degraded reasoning.

What this actually costs

Some math from real situations I've watched. Your numbers will vary:

  • A loop session at 4 messages/min on a ~$0.015 average call cost: about $3.60/hour. One bad afternoon = $30.
  • Agent rewriting 800 lines per task instead of 30: roughly 25× the input tokens. A weekend project that should have cost $5 in API calls costs $120.
  • Hallucinated function signatures that ship: not a token cost. A debugging cost. 2–4 hours of human time per incident, which at any reasonable hourly rate dwarfs the entire model bill for a month.

The token bill is not the only cost, and often not the worst one. The worst one is shipped code that's confidently wrong, because the wrongness is invisible until production.

What to actually do

Three things that change the economics:

1. Set a per-task budget — in time, not tokens. Decide before you start: "I'll spend 20 minutes on this." If the AI hasn't solved it by then, the prompt is wrong, the tool is wrong, or the problem needs to be decomposed. Throwing more iterations rarely fixes any of those.

2. Switch tools mid-session. If Cursor is looping, paste the state into Claude Code or Codex with a fresh framing. Different model, different constraints, often a different answer. Tool fluency beats tool loyalty.

3. Sometimes the right answer is to write it yourself. If you've been arguing with the AI for an hour about a 30-line function, write the function. The AI is good at most things, but not all things, and the time cost of fighting it sometimes exceeds the time cost of doing it.

Plus two reinforcers from the fixes above:

4. Stop loops at two. Same failure twice = the AI does not have the answer. More iterations won't surface it.

5. Pin context manually. Paste the actual schema, the actual function signature, the actual error message. Don't make the AI infer what it could just read.

The take

The expensive thing about AI builders isn't the price per call. It's the rate at which a confident model burns tokens in pursuit of a wrong answer it doesn't know is wrong.

The fix isn't smarter prompts or bigger models. It's a tighter feedback loop: shorter sessions, stricter constraints, manual interventions when the agent is clearly off track.

Treat the model like an intern who never tires and never doubts. The "never doubts" part is the dangerous one. You have to do the doubting for both of you.


If you want a more concrete walkthrough — the multi-model workflow that catches what the builder rationalized away, verification loops, escalation rules — /coding goes deeper.

Get these in your inbox every Sunday — no daily spam, just the weekly note plus a few hand-picked links. Subscribe on the homepage.