[Bug] Scheduled routine consumes entire token quota in single execution without safeguards
Bug Description
Subject: Scheduled routine (Claude Code Remote) consumed my entire token quota in a single run
Body:
Hello,
I'm reporting unexpectedly high token consumption from a single Claude Code Remote scheduled trigger run, which exhausted my token quota in one execution.
What happened:
I manually triggered a scheduled routine to validate its configuration (a dry run). The routine's single agent session was configured to clone 32 repositories (listed as sources) and run three review tasks across all of them. This one run consumed the large majority of my token quota — far beyond what I anticipated for a validation run.
Traceable details:
- Session ID: cse_01C8eDo1SKMk56GNiF7jLaP1
- Trigger ID: trig_01DgFKgzzASAmr2kGaWRrnk8 (name: veille-hebdo)
- Triggered manually on 2026-07-11, ~08:09 UTC
- Likely cause: a single-session design cloning 32 repositories and processing 3 review tasks over all of them, with no context isolation between tasks.
My questions:
- Can you confirm the token usage attributed to this specific session, and whether it aligns with the work actually performed?
- Given this was a one-off validation run whose cost was not foreseeable from the configuration, would you consider a credit/adjustment for this session's consumption?
- Is there any built-in safeguard (per-run token cap or budget limit) for scheduled Claude Code Remote triggers that I can enable to prevent a single run from draining my quota again?
I've since disabled the trigger to prevent any further runs. Thank you for your help.
Best regards,
Sébastien
Environment Info
- Platform: darwin
- Terminal: ghostty
- Version: 2.1.197
- Feedback ID: 8e99d083-a441-48aa-be71-61b082d2bdee
Errors
[]Showing cached comments. Read the full discussion on GitHub ↗
4 Comments
Hi, following up on this — any update on whether this token usage was expected for this kind of routine config, or whether a per-run budget cap for Claude Code Remote scheduled triggers is being considered? Happy to provide more details if useful. Thanks!
The detail that makes this a design problem rather than a surprise is in your own diagnosis: a single session cloning 32 repos with no context isolation doesn't cost 32×N, it costs closer to Σ(growing context) — every task after the first carries the accumulated context of all prior repos, so the token curve is superlinear in the number of sources. That's why the cost was unforeseeable from the config: the config lists 32 sources and 3 tasks, but the actual spend is a function of how context accretes across them, which isn't written anywhere in the config.
Two things address it, at different layers:
The general trap is that the only number that mattered — total cost — was emergent from the run, not declared by it. The enforcement that survives that has to sit outside the run and fail closed at a clean boundary; a limit the run reports to itself is one it has already blown past by the time it notices.
Thanks for the thoughtful breakdown, @deemwario — the superlinear-cost framing (Σ of growing context rather than 32×N, because context accretes across sources in a single un-isolated session) matches exactly what I observed, and the "dry run should estimate statically without a single model call" / "cap at the unit boundary, fail-closed outside the run" distinction is the right way to put it.
▎
▎ For what it's worth, I've since restructured my own setup away from the single-session fan-out, so this is no longer an active pain point on my end. Leaving the issue open as it still points at a real design gap — hoping for an official take on whether a per-run budget cap for scheduled triggers is on the roadmap. Appreciate you taking the time.
Glad restructuring to per-source isolation fixed it in practice — that's the load-bearing change, and it's telling that the fix was architectural rather than a config flag.
Agreed on leaving it open for an official take. The one thing a per-run cap alone won't cover: the cap has to fail closed at the unit boundary, i.e. refuse to start unit N+1 once cumulative spend crosses the ceiling, not just abort mid-unit or report after. A cap the run enforces on itself is one it can already have blown past by the time it checks; the enforcement that survives sits outside the run and gates each unit before it begins. A static dry-run estimate (units × tokens-per-unit, zero model calls) is the other half — it turns 'discover the cost by paying it' into 'see the cost before you commit.' Both are cheap to state and, from experience, the difference between a scheduled routine you can trust unattended and one you can't.