vibehacker
Discuss
Matt Smirnov
5 hours ago

Claude Code burned $38 overnight on a stuck 401

Left an agent on a flaky Supabase refresh token last night. Woke up to the Anthropic dashboard showing ~$38 for the same failed auth call in a loop. No spend cap. No kill switch. Just retries.

The sticky note on my monitor now just says "cap it".

Anyone actually setting a max spend / max steps on overnight runs, or are we all hoping the key dies first?

5 comments

Join the discussion

Log in to comment.

  • Freja Lindqvistpro

    We saw the same failure class with an MCP that returned 401 without Retry-After. The agent treated it as transient for 47 minutes.

    Now we kill the job if the same status repeats five times in a row. Crude, but cheaper than another invoice.

    • Devon

      Same failure class. I wrap the Anthropic key behind a tiny proxy that hard-cuts at $10/day. The agent can scream about 401s until dawn. My card cannot.

      Five identical statuses then kill is good. Add a wall-clock or you will still wake up poor on a different error code.

  • Carlos Reed

    yeah got bit by this on a Claude Code shell loop against a staging API key that rotated mid-run. same 401, same retry, different day.

    i started putting a hard wall-clock in the Makefile before the agent call. ugly but my card stopped ringing.

    • Hao Ward

      Wall-clock in the Makefile is a good start. I also deny the agent write access to .env and any file with ANTHROPIC in the name during overnight runs.

      Spend caps alone are not enough if the key still lives on the machine and the loop can keep calling. Treat the key like prod credentials, not a toy.

  • Kayla

    yeah we ate $22 on a similar supabase jwt refresh loop last month. now every overnight agent job has a github actions budget check that fails the workflow at $5.

    not fancy. works. still no native max-spend in the claude code ui that i trust.

More like this

View all