A 39-run failure loop and $45.61 of overage: taking apart one Claude Code bill
On 16 November 2026 a developer, hirobaw, opened issue #110395 on the anthropics/claude-code repo. The title says most of it: Claude Code built recurring AI jobs with no cost estimate and no spending cap, and the user's weekly allowance plus USD 45.61 of overage went with them. $45.61 is not a scar

On 16 November 2026 a developer, hirobaw, opened issue #110395 on the anthropics/claude-code repo. The title says most of it: Claude Code built recurring AI jobs with no cost estimate and no spending cap, and the user's weekly allowance plus USD 45.61 of overage went with them.
$45.61 is not a scary number. What makes the issue worth reading is that every step that led to it is ordinary. Nobody did anything reckless. An agent was asked to set up some automations, it did, and the bill arrived later.
This post walks through the numbers in the issue, shows which part of them nobody could have seen from a usage page, and ends with a check you can run on your own logs in about a minute.
Everything below is from the issue body (link at the end). In October 2026, Claude Code, running Opus in the Claude desktop app, set up recurring automations on a third-party agent service. The jobs were simple condition checks, things like "new mail?" or "is the process running?". Each one was built as a full AI execution, run every 5 to 10 minutes.
The issue also notes that the jobs had no run-count or cost estimate, no check against the provider's weekly limit, no spending cap and no brake on repeated failures.
Do the arithmetic on the baseline the issue gives:
580 runs × 40,000 tokens = 23.2M tokens a day.
At that rate, 361.6M tokens would last about 15.6 days. It lasted 3.83 days, which works out to roughly 94M tokens a day, about four times the stated baseline.
The issue doesn't break down where the other three quarters went, so I won't guess. But it tells you something useful about how these bills happen. The designed load, the one you could estimate up front, explains a quarter of the spend. The rest is behaviour: retries, failures, runs that took longer than planned. The 39-in-a-row failure loop is one visible piece of that.
That is the pattern behind most surprise AI bills I've read about. The plan was fine. The exceptions to the plan are what cost money, and exceptions don't show up in a daily total until it's too late.
A usage dashboard answers "how much did I spend?" It's good at that. It's bad at "why?", because the why lives one level down, in individual tool calls.
A failure loop looks like this in a log: the same tool, called with the same input, again and again, each call failing. On a daily chart it looks like a busy day. In the log it's obvious. The first try is normal. The second try is reasonable. By the third identical failure, every further call is waste, because nothing about the input has changed.
So the useful question isn't "what did I spend this week". It's "where did the same call repeat three or more times, and what did the repeats cost?"
The issue's own request lists the fixes it wanted: cost and limit estimation, and spending safeguards when Claude Code creates scheduled or recurring jobs. Until something like that ships, here's what you can do yourself:
None of these need a new tool. They need you to know that a loop is happening, which is the part that's hard.
Claude Code keeps a JSONL transcript of every session under ~/.claude/projects/. Each assistant message lists the tool calls it made. Repeated identical calls are easy to find.
Save this as loops.py and run python3 loops.py. It reads your logs locally and prints nothing but counts and the first 120 characters of each repeated call.
import json, glob, os from itertools import groupby for path in glob. glob ( os. path. expanduser ( "~/.claude/projects/**/*.jsonl" ), recursive = True ): calls = [ ] for line in open ( path, encoding = "utf-8", errors = "replace" ): try: d = json. loads ( line ) except ValueError: continue content = ( d. get ( "message" ) or { } ). get ( "content" ) if d. get ( "type" )!= "assistant" or not isinstance ( content, list ): continue for b in content: if isinstance ( b, dict ) and b. get ( "type" ) == "tool_use": calls. append ( b. get ( "name", "" ) + " " + json. dumps ( b. get ( "input" ), sort_keys = True ) [: 120 ] ) for call, run in groupby ( calls ): n = len ( list ( run ) ) if n >= 3: print ( n, "x", call, "|", os. path. basename ( path ) ) Enter fullscreen mode Exit fullscreen mode On a test log with one bad loop, the output is a single line:
10 x Bash { "command": "npm test" } | s2.jsonl Enter fullscreen mode Exit fullscreen mode How to read it:
The script counts calls; it doesn't price them. If you want the dollars, the free tool linked below does the same check, prices every call after the third try at list price, and lists your ten most expensive sessions. It runs either as one Python file or in a browser tab with nothing uploaded.
If you run the self-check and find something odd, post the count (not the content) in the comments. I'm curious how common 10x-plus loops are in the wild.
Free tool (MIT, runs locally): https://github.com/6hn68/ai-bill-watchdog-free