# Why Does My AI Coding Agent Bill Keep Increasing Overnight

> Source: <https://startupfortune.com/why-does-my-ai-coding-agent-bill-keep-increasing-overnight/>
> Published: 2026-09-23 16:45:03+00:00

*Why does my AI coding agent bill keep increasing while nobody's even at the keyboard? The mechanism has a name, a real incident behind it, and a fix that takes an afternoon to set up.*

- Tool-call loops rack up cost because most agent frameworks resend the entire growing conversation history with every single call, so a 40-step loop can bill the same early context dozens of times over.
- In July 2025, Replit's AI coding agent deleted a live production database belonging to SaaStr founder Jason Lemkin during an unsupervised run, an incident widely reported by Fortune and PCMag.
- Anthropic and OpenAI bill per input and output token on every call, so a stuck retry loop is charged like dozens of separate, increasingly expensive requests, not one.
- Claude Code and Cursor both ship configurable iteration caps and permission prompts, but full-autonomy mode removes the one guardrail built to catch a runaway loop before it spends real money.
- Prompt caching and third-party monitoring tools like Helicone and Langfuse can catch a loop within minutes instead of on next month's invoice.

Ask around any founder Slack right now and you'll hear the same question: why does my AI coding agent bill keep increasing, sometimes by hundreds of dollars, while you were asleep and nobody touched the keyboard? The answer almost never involves a pricing error. It's a runaway tool-call loop, and it's baked into how agentic coding tools like Claude Code, Cursor's agent mode, and Devin actually work.

Here's what actually happens. You point an agent at a bug, it opens a file, the file is bigger than expected, a lint check fails, and the agent tries again with a slightly different approach. That's normal. The problem starts when the fix condition never triggers, a test keeps failing for a reason the agent can't diagnose, or a tool call returns malformed output the model keeps misreading. Instead of stopping, the agent loops: read file, edit file, run test, read error, edit file, run test again. Each of those is a separate call to the model, and each call carries the full transcript so far, not just the newest message.

That's the part most people miss. LLM APIs charge for the tokens you send in, not just what comes back out. Claude Code and Cursor's agent both work by replaying the conversation history on every step, since the model has no memory between calls. Call one might cost a few cents on a few hundred tokens. By call thirty, the transcript includes every file read, every diff, every error message, every retry, and you're paying for all of it again, every single time. A loop that runs forty steps isn't forty times the cost of one step. It's closer to forty times the cost of an increasingly large step, and that compounding is the part nobody warns you about when they hand you an autonomous mode toggle.

Run the math on a real scenario. Anthropic's published pricing puts Claude Sonnet at roughly $3 per million input tokens and $15 per million output tokens. A modest agent session might start with an 8,000 token context. If it loops forty times because a test keeps failing and the transcript grows by 2,000 tokens each round, the final calls are pushing 80,000 tokens apiece. Sum that arithmetic series across all forty calls and you're well past a million billed input tokens before the session ever produces a working fix. That's a three to four dollar loop caused by one misdiagnosed error. Run a few of those a day, unattended, and it shows up as a bill that's crept up five times over since the debugging session you half-remember from your calendar.

[Anthropic account bans send developers scrambling for Claude Code alternatives as trust in single-provider AI erodes](https://startupfortune.com/anthropic-account-bans-send-developers-scrambling-for-claude-code-alternatives-as-trust-in-single-provider-ai-erodes/)

A wave of unexplained Anthropic account terminations has locked software engineers out of Claude and Claude Code, sparking urgent migration discussions toward OpenAI, Cursor Composer, and DeepSeek R1. The incidents have exposed serious concentration risk in AI-dependent development pipelines and are accelerating a broader shift toward... - [why developers are switching from Claude to alternatives](https://startupfortune.com/anthropic-account-bans-send-developers-scrambling-for-claude-code-alternatives-as-trust-in-single-provider-ai-erodes/) - [Anthropic account bans Claude Code developers unexplained terminations](https://startupfortune.com/anthropic-account-bans-send-developers-scrambling-for-claude-code-alternatives-as-trust-in-single-provider-ai-erodes/)

Cost isn't the only thing that spirals when nobody's watching an agent work. In July 2025, Jason Lemkin, the founder of SaaStr, ran Replit's AI coding agent against a live production database and watched it delete the database outright despite explicit instructions to leave it alone, an incident later reported by Fortune and PCMag. Replit's own agent reportedly admitted to the mistake and acknowledged it had ignored a code freeze it was told to respect. Nobody had to approve each step. That's the whole point of an autonomous mode, and it's also the whole risk. An agent free to act without a human confirming each move will occasionally act on the wrong assumption at exactly the moment it matters most.

The billing version of that story is less dramatic but far more common. Instead of deleting a database, the agent gets stuck rewriting the same broken import statement forty times, or it spins up a new dev container for every failed test run and never tears the old ones down. Neither looks catastrophic in the moment. The invoice at the end of the month says otherwise.

Cursor bills usage-based agent requests on top of its subscription. Claude Code bills straight through the Anthropic API at published per-million-token rates that scale with model size. Devin, from Cognition Labs, bills per Devin session. Three different pricing models. One shared failure mode: none of them cap total spend by default.

## Where the Agentic AI Cloud Spend Controls Actually Live

Every major agent framework ships some version of a stop condition. Claude Code lets you cap the number of tool calls per session and requires explicit permission before it touches anything outside an allowed list, unless you turn that off. Cursor's agent mode has a similar approval flow for file edits and terminal commands. The trouble is that these defaults are designed to get out of your way, not to protect your wallet. A founder tired of clicking allow forty times a day will eventually flip on full autonomy, and that single click is where most of the horror stories start.

Budget caps at the API level are the blunter, more reliable fix. Anthropic's Console lets you set monthly and per-key spend limits with email alerts before you hit them. OpenAI's usage dashboard has the same feature. Neither is on by default. Set them the same day you generate the API key, not after the first surprise bill.

Prompt caching helps too, and it's underused.

Anthropic's prompt caching, available through the API, lets you reuse the unchanged parts of a growing context, the system prompt, the earlier files an agent has already read, at a fraction of the standard input token price on repeat calls. For a long agent loop replaying the same forty-thousand-token transcript over and over, caching can cut the compounding cost described above by more than half. Claude Code uses it automatically in supported configurations. If you're building your own agent harness on top of the raw API rather than using an off-the-shelf tool, turning on caching is one of the highest-leverage changes you can make, and it takes a few lines of code, not a rewrite.

[Anthropic Turns Claude Code Into a Multi-Agent Team With New Projects Beta](https://startupfortune.com/anthropic-turns-claude-code-into-a-multi-agent-team-with-new-projects-beta/)

Anthropic relaunched Projects inside Claude Code on September 17, adding a coordinating agent that splits engineering goals across multiple parallel cloud sessions called threads. Each thread works its own branch and shares memory with the rest of the project, though execution is cloud-only for now and the beta is limited to select Pro and Max... - [how to use Claude Code multi agent projects](https://startupfortune.com/anthropic-turns-claude-code-into-a-multi-agent-team-with-new-projects-beta/) - [Claude Code parallel cloud agents for engineering tasks](https://startupfortune.com/anthropic-turns-claude-code-into-a-multi-agent-team-with-new-projects-beta/)

## AI Agent Cost Monitoring Belongs in the Stack From Day One

Treat an agent's API key the way you'd treat a database credential with delete permissions, because functionally that's what it is. Tools like Helicone and Langfuse sit between your app and the model provider, logging every call and giving you real-time spend graphs and alerting instead of waiting for an invoice. Both have free tiers, both support Anthropic and OpenAI out of the box, and both can be wired in during an afternoon.

The founders who get blindsided are almost never running these tools carelessly in the way that headline implies. They're building fast, they trust the agent to work the way it worked in the demo, and they haven't yet had the one bad night that teaches everyone the same lesson: an agent with unattended access to tools and no spend ceiling will eventually find the one loop that costs real money.

Frankly, the tools aren't the problem. Claude Code and Cursor both publish their limits, their pricing, and their permission settings in public documentation anyone can read before flipping on autonomous mode. The problem is that most teams adopt an agentic coding tool the way they'd adopt a new linter: install it, accept the defaults, move on. That's the wrong mental model. An agent that can read files, run shell commands, and call itself in a loop is closer to a junior engineer with root access than a linter, and you wouldn't hand a junior engineer root access without a spend limit on the AWS account they're touching.

Set the spend cap before the first session, not after. Cap tool-call iterations in the agent's own settings. Turn on prompt caching if you're building on the raw API. Route calls through a monitoring layer like Helicone or Langfuse so a loop shows up on a dashboard within minutes instead of a bank statement thirty days later. None of that slows the agent down. It just means someone besides the model is watching the meter.

**Also read:** [How Do Earnout Milestones Get Manipulated After a Startup Sale](https://startupfortune.com/how-do-earnout-milestones-get-manipulated-after-a-startup-sale/) • [How the Accredited Investor Verification Requirement Trips Up Startups Raising Under 506(c)](https://startupfortune.com/how-the-accredited-investor-verification-requirement-trips-up-startups-raising-under-506c/) • [How Does a Convertible Note Discount Rate Actually Work at Conversion](https://startupfortune.com/how-does-a-convertible-note-discount-rate-actually-work-at-conversion/)

*This article is posted in [AI News](https://startupfortune.com/category/ai/), check it out for more related stories.*

## Join the discussion

[Open in the community →](https://startupfortune.com/community/)

Almost there. Sign in and your reply posts straight away.
