Agent gave false 'not hanging' reassurances while a script it wrote burned 15,861 API calls over 13 hours
Session ID(s)
c901e52d-1ab4-4436-887f-5b73c41c40b7 (most recent activity in this conversation) — also saw e8593581-0c0b-44ca-973b-6ac1fed86255 referenced earlier in the same conversation. Unclear why two IDs appear; worth reconciling.
What happened
Claude Code wrote a Python script that called the Google Places API (New) Text Search endpoint in a paginated loop across ~20 towns. The generated code had a bug: it followed Google's nextPageToken even when the returned places list was empty, with no check for repeated empty pages and no hard iteration cap. On one query, this caused an infinite loop that ran for roughly 13 hours, firing a request approximately every 2 seconds.
Separately, Claude ran the script in a background shell piped through tail, which buffers all output until the process exits — so there was no visible output the entire time it was stuck, making the hang invisible to both of us.
The bigger problem
I asked multiple times whether it was hanging. Claude repeatedly told me it was fine — citing things like "no active network connections in this snapshot" and "the design is bounded, no infinite loop is possible" — without actually checking real usage data. Those reassurances were wrong. When I pushed back, Claude checked Google Cloud Monitoring directly and found the real number: 15,861 API requests made, ~$245.60 in usage cost. That happened to be fully offset by promotional credits on my billing account, so net cost was $0.00 — but Claude had no way of knowing that when it gave the earlier reassurances. If I hadn't had credit headroom, this would have been a real, unexpected charge with zero warning.
Impact
- 15,861 wasted Google Places API requests over ~13 hours
- $245.60 in Google Cloud usage (covered by credits in my case; could be a real bill for someone else)
- Multiple incorrect "it's fine, not hanging" statements from Claude before it actually verified anything
What I'd like investigated
- Why the agent asserted certainty ("not hanging," "bounded," "no risk") on a cost-relevant question without checking real data first, more than once
- Whether there's a way to warn the agent/user by default when a long-running background shell task is piped through a buffering command like
tailwith no live output, since that's what hid the bug for 13 hours - Whether Claude Code should encourage/require some kind of spend guardrail by default when an agent writes code that calls a metered third-party API
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗