Safeguard
AI Security•

Why AI agent bills balloon: the hidden costs inside agent loops

Agents resend context on every step, run idle check-ins and spawn helpers. Here are the documented sources of token growth and how to cap each one.

Safeguard Security Team
3 min read

An agent bill grows faster than usage because every step resends the conversation so far, tool results pile up, and helpers run their own contexts. Anthropic's Claude Code documentation lists the main causes: long context, cache misses, scheduled tasks, subagents, teammates and compaction. Each has a control.

Every step is a new request

An agent that reads a file, runs a test and edits code makes several model calls for one visible task. Anthropic's cost documentation says Claude Code sends the full conversation with every request, and each time a tool is used another request carries that batch of results. Prompt caching lowers the price of re-reading history, but the tokens still count toward your usage.

The documented multipliers

From Anthropic's Claude Code cost page, read on 19 October 2026:

  • A session open all day can draw heavily even for a one line question, because the whole conversation is sent.
  • A message after a break longer than the cache lifetime misses the cache and reprocesses the full context. The lifetime is an hour on a subscription and five minutes by default on an API key.
  • A scheduled task fires on its interval even while the session is idle, sending the full context each time.
  • Messages from another session can start a new turn in an idle session.
  • Each subagent sends its own requests on top of the main conversation.
  • Agent teams use approximately 7 times more tokens than standard sessions when teammates run in plan mode.
  • Thinking tokens are billed as output.

The page also describes goal check-ins, capped at three idle check-ins per goal in recent versions.

Server tools and tool definitions

Anthropic's pricing page says tool definitions count as input tokens, and server side tools such as web search can add usage based charges on top of tokens. A long list of connected tools is a standing input cost on every call.

Controls that work

  1. Set a hard spend limit on the API workspace the agent uses. See API spend caps and usage tiers.
  2. Clear the conversation between unrelated tasks, and compact with instructions about what to keep.
  3. Keep teams of agents small, and shut teammates down when done.
  4. Use a smaller model for simple subagents.
  5. Disable tool servers you are not using.
  6. Cap loops in your own code: a maximum number of steps, a time limit, and a token budget per task.
  7. Review the scheduled tasks and check-ins that run while nobody is watching.

See also reduce Claude Code token usage: a checklist and agentic AI budget explosions and cost controls.

Spend is not the only risk

An agent that loops can also change things. Safeguard's autonomous remediation, which opens fix pull requests, is off by default and every category starts on Manual, so a human decides what an automated change is allowed to do. Treat any agent you run with the same default: limit what it may do before you limit what it may spend.

Quick check

Why did my cost jump when I did less work?

Idle schedules, check-ins and cache misses after a break can all send your full context without you typing anything. Check the usage breakdown for the flagged behavior.

What is the single best control?

A hard spend limit on the credential the agent uses, plus a step limit in your own code.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.