Per-agent caps still let a multi-agent run overspend in aggregate: ten threads each "under budget" blow past the total, and a sub-agent or compaction call drawing context after the work is done is invisible to any single counter. Settle every thread, sub-agent, and compaction call against ONE shared ledger, abort each turn at its next usage-accounting boundary when the ledger hits zero, and feed the remaining balance back into the model's context so it steers its own spend.
Run Every Agent Thread Off One Shared Token Ledger That Aborts at the Budget Line
Unlock this tip โ and 105 more
This is one of 106 advanced, fact-checked tactics reserved for Pro. Get the full 128-tip library, a searchable archive, and a new tip every morning. Free for 7 days, then $9/mo.
Prefer to browse? The 22 Beginner tips are free forever.
More in Measurement & Budgeting
Count Tokens Before You Hit Send, Not After the Bill Arrives
Measure a prompt's token count before sending it, so you catch oversized context while trimming it is still free.
Set Hard Spend Caps in the Provider Console
Configure provider-side usage limits, budgets, and alerts so a bug, a retry storm, or a leaked key cannot quietly run your bill far past a ceiling you set in advance.
Cap the loops by count, not tokens: spawn and search limits in Claude Code
Claude Code 2.1.212 added session caps on subagent spawns and WebSearch calls, both defaulting to a non-binding 200. Lower them to match your actual workload so a mis-planned agent hits a hard stop at 12 searches instead of quietly burning a full context window and the spend behind it.