↑ Incidents / Looping

AI Agent Infinite Loop Cost: How a Claude Code Hook Deadlock Ran for Six Days

Incident report · 5 min read ·

What the operator reported

On November 4, 2026, a Claude Code user filed a public bug report describing scheduled agent sessions that kept retrying the same refused file edit for six days. According to the report, the loop ran from October 22 to October 28, 2026, mostly in headless runs started by a scheduler, and consumed about $9,364 of extra usage through repeated automatic credit reloads. The reporter used Claude Code 2.1.312 with an Opus model on a Max plan with extra usage enabled.

The reporter states up front that both hooks involved were their own configuration. They filed it as a product defect because nothing in the client, the server or billing stopped a session that repeated one denied action thousands of times. As of November 9, the public thread shows no reply from Anthropic. The figures below come from the reporter and have not been independently confirmed.

How the loop formed

Claude Code lets operators attach hooks, small scripts that run at defined points in the agent's work. A Stop hook refused to let a turn end until the agent had written to a journal file, BUILD_LOG.md. A PreToolUse hook, which checks tool calls before they run, denied writes to paths it believed another session owned.

The two rules collided on the same file. The Stop hook checked the journal through a symlink, while the ownership guard matched the real path and found a stale claim left by a session two weeks earlier. Each cycle therefore went the same way. The agent tried to edit the journal, the guard refused with "Another chat owns this path," the Stop hook blocked the end of the turn and asked for the journal write, and the agent tried the edit again.

The reporter counts nine sessions in the loop window, seven of them scheduled runs. The worst session made roughly 10,000 refused edit attempts, and the next two made about 2,000 and 750. Across the loop sessions they estimate around 2.4 billion tokens, almost all cache reads of the same context. Automatic reload topped up credits 18 times between October 22 and 28, they say.

The report does not say when or how the operator first noticed the loop, so the detection time is unknown. The reporter links two earlier open issues that describe similar Stop hook loops, #43906 from April and #55754 from May 2026.

What the agent's behavior showed before the bill arrived

The clearest pattern in the report is repetition. The same tool, the same path and the same denial reason came back thousands of times in one session, and the reporter points out that the client already sees each of those refusals. In our reading, a count of identical tool calls per session would have looked very different from a normal run.

Token volume is a second signal. After the fix, the reporter measured 42.8 million tokens on November 4 and 60.2 million on November 5 up to 08:30 ET, compared with 6 to 18 billion per day during the loop. A per-session comparison of call counts or tokens against earlier runs would likely have shown an abrupt change early in the window. That is an inference: the report publishes no per-hour data, so we cannot say how quickly any specific alert would have fired.

Steps you can take today

  • Give every hook that can block a turn its own retry limit. The reporter's fix releases the turn after three blocks in a session and writes a pending note instead. The counter lives in a state file keyed by session ID, because each hook runs as a separate process.
  • Put a spend or turn ceiling outside the agent configuration for scheduled runs. One commenter on the thread notes that a breaker living in the same configuration that caused the loop can fail the same way, and suggests turning off automatic reload for scheduled runs until a built-in ceiling exists.
  • Test hooks together, including path aliases. Another commenter suggested a harness that alternates the conflicting conditions and treats a symlink and its target as the same file. The reporter ran it and saw the fourth Stop evaluation release the turn.
  • Alert on repeated identical denials and on token use per session, not only on the monthly bill. A monthly limit can be reached before anyone looks.

The cause here was a small conflict between two of the operator's own hooks. It became expensive because the runs were unattended and nothing between the agent and the bill counted repeated refusals. Each of the steps above addresses one of those two conditions.

Kyde watches AI agents in production and quarantines one that stops behaving like itself.

Sources

  1. GitHub issue opened November 4, 2026, with the reporter's follow-ups on November 4 and 5 and comments through November 7: anthropics/claude-code#107256. Read November 9, 2026.
  2. GitHub issue, April 5, 2026: anthropics/claude-code#43906
  3. GitHub issue, May 3, 2026: anthropics/claude-code#55754