AI Agents & Skills

A forgotten /loop and a four-figure API bill: what repeated agent runs really cost

TL;DR

A story circulating in the community: a developer ran /loop to check a PR every 30 minutes, forgot it, and woke up to an API bill of several thousand dollars. Why: each iteration resends the entire conversation, and because the default cache only lives 5 minutes, every iteration paid full price for that context.

Why so expensive?

  • Every model call resends the full context (system prompt, history, tool results) — the longer it is, the more each turn costs.
  • Prompt caching makes repeated context much cheaper, but the default TTL is 5 minutes (a 1-hour option exists at a higher write price).
  • Looping every 30 minutes → the cache has expired → each iteration rewrites the cache from scratch.
  • Each iteration also appends new results to history → the context keeps growing.

How prompt caching is priced

TypeRelative to base input price
5-minute cache write1.25×
1-hour cache write2×
Cache read0.1× (lower on some newer models)

How to put it to work

  • Know how to stop it: a fixed-interval loop (/loop 30m …) isn’t stopped by Esc — ask Claude to cancel it. Recurring tasks expire after 7 days.
  • Use the right tool: long-running jobs belong in cloud/desktop scheduled tasks or GitHub Actions with a fresh session each run, not one long session looping forever.
  • Set spend limits and budget alerts in the API console; review usage daily.
  • Keep context lean: /clear or start a new session for recurring work; keep the looped prompt short and specific.
  • Right-size the model: checking PR status doesn’t need the most expensive model.