[FEATURE] Detect and warn when usage velocity suggests a runaway process
- [x] I searched existing issues and didn't find a duplicate
- [x] This is a single feature request
Problem Statement
On Max plans, there is no per-token billing to create natural friction when something goes wrong. If Claude enters a tight loop (recursive agent spawning, repeated failed tool calls, retrying the same action endlessly), it can burn through $50+ of quota in minutes with no warning.
This is the equivalent of a runaway process in programming. Every OS has CPU/memory spike detection. Claude Code has nothing comparable.
Real scenario: a session burned through $50 of a Max plan in a matter of minutes. There was no indication anything was wrong until the quota was gone. The user had no opportunity to intervene. The only thing that stopped it was having auto-reload turned off — without that, it would have continued unchecked.
Proposed Solution
Track usage velocity (tokens consumed per unit of time) and surface a warning when it spikes abnormally. Something like:
"Heads up — you've used X% of your daily quota in the last Y minutes. This may indicate a runaway process. Continue?"
The key behaviors:
- Warn, and optionally pause — give the user a chance to inspect what is happening before continuing. Throttling is acceptable as long as the user is notified and can choose to proceed.
- Pattern detection — flag known runaway signatures: tight retry loops, recursive agent spawning, repeated identical tool calls that keep failing.
- Configurable threshold — let users set their own sensitivity (e.g., "warn me if I burn more than 20% of quota in 5 minutes").
- No silent throttling — the worst outcome is silently slowing down without telling the user why.
Alternative Solutions
Currently there is no workaround. Users only discover the problem after their quota is exhausted. You can manually watch the usage dashboard, but that defeats the purpose of an autonomous coding agent. The only accidental safety net is having auto-reload disabled, which is not a real solution.
Priority
High
Feature Category
CLI
Use Case Example
- User starts a complex multi-agent task
- One agent hits an error and begins retrying in a loop
- Each retry spawns new context, consuming tokens rapidly
- After 3 minutes and 25% of daily quota consumed, Claude Code surfaces: "Unusual usage spike detected — 25% of your daily quota used in 3 minutes. This could be a runaway process. [Continue] [Pause] [Abort]"
- User inspects, finds the loop, aborts, and still has 75% of their quota for the day
Environment
- Claude Code Version: 2.1.87
- Platform: Max plan
- Operating System: macOS 26.3.1 (Apple M2 Pro, 16 GB)
- Terminal/Shell: VS Code 1.113.0 with claude-code extension 2.1.87
Additional Context
This is especially important for Max plan users running autonomous/background agents where the feedback loop is longer. The pattern is well-understood in computing — every process monitor, cloud billing system, and CI pipeline has runaway detection. Claude Code should too.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗