# 30 Calls for a 3-Call Task: Stop Agent Token Loops

> Agents burn tokens retrying the same failing approach 30 times. Loop detection, attempt budgets, and the re-prompt rule. Inside.

Source: https://boringpush.com/blog/ai-agents-token-waste-loops-fix

## An $18 Tuesday with nothing to show

Watch it happen in real time: an agent hits a failing test, "fixed" it, re-ran, failed differently, "fixed" that, re-ran — thirty tool calls deep, context window stuffed with error logs, each attempt more expensive than the last because the conversation kept growing. Final result: the original bug plus two new ones, $18 in API charges, and an afternoon gone.

The task needed three calls: read the error, fix the line, verify.

Ai token waste loops are the meter running while the car is stuck in mud — spinning faster, sinking deeper, billing by the rotation.

## Attempts vs progress, priced

| Loop shape | Calls burned | Progress | Cost signal |
|---|---|---|---|
| Healthy task | 3–8 | Done | Normal |
| Retry loop (same error) | 20–40 | Zero or negative | $10–25 gone |
| Flail loop (new errors each) | 30–60 | Negative (new bugs) | $20–50 + cleanup |
| Context-bloat loop | Growing per call | Shrinking (lost thread) | Superlinear pricing pain |
| Maxed-out session | 100+ then compact | Amnesia (restarts blind) | Full price, no product |

Three things loop mechanics teach:

1. **Errors compound in context.** Every failed attempt appends logs, diffs, and apologies to the window — attempt 25 reasons over 24 failures' worth of noise at premium token prices. Loops don't just waste calls; each call costs more than the last while succeeding less. The meter accelerates into the wall.
2. **Agents can't feel stuck.** No frustration, no embarrassment, no "let me step back" — just cheerful attempt 31 with the same broken theory. Stuck-detection is a human sense models lack entirely; the session needs an external tripwire because the internal one doesn't exist.
3. **Max plans hide the bleed.** $200/mo subscriptions make per-loop costs invisible until renewal math — thirty loops a month is a second subscription wearing debugging clothes. Metered users feel each loop; plan users discover them quarterly. Invisible waste is still waste, just better dressed.

The 67%-debugging post priced the time. This one prices the tokens.

## Ai token waste loops breaker

Detect repetition, budget attempts, force fresh thinking — the loop rules below, enforced by habit and hooks.

**Step 1 — Trip the wire at three identical failures.**

```md Example session rule
Same error 3x → STOP. No fourth attempt with the same theory.
Report: what was tried (3 lines), what each produced (3 lines),
and two alternative theories before continuing.
```

Three is the number: once is signal, twice is confirmation, three times is loop. The forced report converts spinning into thinking — writing the alternatives usually surfaces the fix blind retries missed.

BoringPush tripwires live in the session rules file, not in hope.

**Step 2 — Budget attempts per task, kill overruns.**

```bash
# task header I write before prompting (30 seconds, saves $20s):
# TASK: fix coupon null (est: 5 calls, hard cap: 12)
# approach budget: 3 attempts per theory, then mandatory re-prompt
# overrun protocol: stop, summarize, fresh session with summary only
```

Estimates plus hard caps turn infinite retries into bounded experiments.

**Step 3 — Re-prompt the human back into the loop.**

```text
Agent's mandatory overrun message (required by my rules file):
"Stuck after 3 attempts on theory X. Tried A/B/C. Alternatives: Y (needs your call),
Z (risky). How should I proceed?"
```

The message does three jobs: stops the meter, transfers the decision to the only intelligence with judgment, and documents the dead ends (no repeat billing for explored territory). A founder answers in a minute what the loop couldn't find in an hour — declaring the theory dead and picking another. Humans end loops; agents extend them.

That's the machine — meters that never spin unwatched.

## The loop ledger, before and after

| Month | No loop rules | Tripwire + budgets |
|---|---|---|
| Runaway sessions (>20 calls, zero progress) | 6 (~$90 burned) | 0 |
| Avg calls per feature task | 22 (loops included) | 7 |
| Monthly token spend | ~$140 | ~$45 |
| Fresh-session restarts | 0 (pride) | ~8 (wisdom) |
| Features shipped | Same count | Same count, fewer midnights |

The downside, owned: tripwires interrupt flow (stopping at three feels premature when attempt four "might work" — it almost never does), and fresh restarts lose ambient context that occasionally mattered. Priced against $95 monthly savings plus six rescued afternoons: interruptions are the product working, not the process failing. Loops feel productive; tripwires are productive.

## FAQ

### How do ai token waste loops differ across models and tools?

Mechanics vary (some retry silently, some narrate each attempt), economics don't: every retry appends context and re-bills it. Chat models loop in conversation; agentic IDEs loop in missions (longer, pricier). The tripwire (3x same failure → stop + report) ports everywhere because it's about failure counting, not tooling. Count failures, not features, across every tool you run.

### Should I use max-mode/thinking models to avoid loops?

Stronger reasoning delays loops (better first theories) but deepens them (more elaborate wrong theories, longer context). The $18 Tuesday ran on a flagship model — capability isn't the cure, tripwires are. Spend model budget on task quality (better slices, better specs), spend process on loop prevention. Brains plus fences beat bigger brains alone, every billing cycle.

### Can hooks auto-detect loops instead of manual rules?

Partially: wrapper scripts counting repeated error signatures per session can fire warnings (a pre-tool hook sketches this in the appendix), but theory-death needs judgment no regex provides. Automate the counting (cheap, tireless), keep the verdict human (one glance at three failures). Counting scales; wisdom doesn't need to — it just needs a seat at attempt four.

### What about background agents running while I sleep?

Cap harder, not looser: overnight missions get smaller slices (one behavior max), tighter attempt budgets (2 per theory), and mandatory morning reports before follow-ups. Sleeping through a loop means waking to a maxed context and a dead end — the most expensive possible outcome (full price, zero product, groggy review). Unattended agents earn trust per success; start them leashed, loosen on evidence.

### Do token-efficient models make this obsolete?

They shrink per-loop cost without touching loop frequency — cheaper spinning is still spinning, and savings get reinvested in bigger loops (Jevons paradox wears an API key). Efficiency lowers bills; tripwires lower waste. Both, always: efficient models inside bounded sessions. Price per token falls yearly; discipline compounds forever.

### How do I budget tokens per feature realistically?

History first: log calls per completed task for a month (typical data says 5–10 for sliced tasks, 15–25 for fuzzy ones). Budget p75 of history plus 50% headroom; investigate overruns as process failures, not cost noise. Budgets without history are guesses; history without budgets is trivia. One month of counting funds a year of accurate caps.

## Keep reading

- [67% Debug AI Code Longer Than Writing It (Escape Here)](/blog/67-percent-debug-ai-longer-fix) — the time tax loops ride inside
- [Antigravity + Next.js: Tame Its 40-File Weekends](/blog/antigravity-nextjs-boilerplate) — fences for long missions that loop longest
- [OpenCode SaaS Starter: Stop the Every-Session Redesign](/blog/opencode-saas-starter) — the file holding the tripwire rules
