vibehacker
Discuss
Matt Smirnov
14 hours ago

Agent burned $41 overnight retrying a 401 on our staging MCP

Left Claude Code running against our staging MCP last night so it could finish a migrations cleanup. Woke up to Anthropic showing ~$41 in overnight usage.

Turns out the access token had rotated at ~2am. The agent just kept retrying list_tables every few seconds, each call burning a full tool-use turn, and never surfaced a hard stop. Terminal looked "busy" so I assumed it was still working.

Anyone else putting a hard spend cap or max-turns kill switch on overnight agent jobs? I feel dumb for not doing this sooner.

5 comments

Join the discussion

Log in to comment.

  • Remy

    yeah this is why i wrap every agent run with a hard timeout now. 90 minutes max, then kill -9. cloud agents fail expensive. local ones at least just hang and make you mad without taking money.

    also: if the tool returns 401, that should be terminal. silent retry is a product bug imo.

  • Cass

    was it an oauth refresh that failed, or did someone rotate the staging secret by hand?

    i had a similar loop last month on a zapier+claude setup — token expired, agent just kept "trying again" for like 6 hours. now i screenshot the usage graph every morning lol. $41 is rough though. did anthropic give you any kind of cap you could set ahead of time?

    • Samir Khan

      In my case it was a rotated client secret, not OAuth refresh — same failure mode though. I added a hard abort in LangGraph when the tool returns 401 twice; no exponential backoff for auth errors.

      Anthropic's org-level spend limit helped after the fact, but it only emails you once you trip it. Wish the SDK exposed a per-run dollar ceiling.

  • Noah

    oof. i started checking the usage page every morning after a smaller version of this ($12 on a hung browser-use loop). now i just set max_turns=40 on anything i leave overnight. still not a real spend cap but at least it stops eventually.

  • Anya Petrov

    this is why i moved overnight jobs to ollama on a spare box. hung loop costs electricity and annoyance, not $41.

    also +1 on 401 being terminal. if the vendor SDK retries auth failures by default thats... a choice.

More like this

View all