"Postmortem: How a runaway LLM loop burned through tokens for 40 minutes before I caught it" from Reddit r/saas, ranked #16. By Independent-Sir3234, 1 score, 0 comments. Data from Daily Trends.
Postmortem: How a runaway LLM loop burned through tokens for 40 minutes before I caught it
- Rank
- 16
- Subreddit
- r/saas
- Author
- Independent-Sir3234
- Score
- 1
- Comments
- 0
- Posted
- 3/27/2026, 10:54:15 PM
- Snapshot
- 3/28/2026, 12:00:00 AM
Links
Content
Sharing this because I have not seen many writeups about LLM agent loops, and it's a failure mode that's easy to hit and expensive to miss. ## What happened I have an agent that pulls data from external APIs and uses GPT-4 to analyze it. One of those APIs changed its response format — a field that used to return a JSON object started returning a plain string. My agent: 1. Called GPT-4 to parse the response 2. Got back invalid JSON (because the input was already wrong) 3. Had a retry handler that asked GPT-4 to "fix" the malformed JSON 4. Got back the same invalid JSON (because the *input* was the problem, not the *output*) 5. Back to step 2 Each cycle: ~2,000 tokens. Every 3 seconds. That's roughly 40,000 tokens per minute. At GPT-4 input pricing (~$0.03/1K tokens), that's about $1.20/min just on input tokens. Over 40 minutes before I caught it, that was roughly $50. If I'd slept through it for 8 hours, it would have been ~$580. ## How I caught it I had heartbeat monitoring with...