LLM Token Usage Spike Alerts
Alert on the shape of usage, not just the total. A baseline, two kinds of threshold, and a cache check catch most spikes.
Short answer: build a baseline from your own recent usage, set a hard per-session cap to stop runaway agent loops, add a per-day trend alert for slow drift, and watch cache hit rate separately, because a broken prompt cache is a common cause of a spike with no change in workload behind it.
Last updated 2026-11-06. Pricing facts are from the provider documentation linked below. Thresholds are starting heuristics, not measured standards.
1. Measure the right four numbers
Every provider response reports token counts. For Anthropic models the usage block separates input_tokens (uncached input), cache_creation_input_tokens, cache_read_input_tokens and output (prompt caching documentation, checked 2026-11-06). Alert on these four separately. A single “total tokens” line hides the difference between a cheap cache read and an expensive fresh token.
These are the same four pillars SigRank scores. If you run a local coding agent, ccusage reads them from session logs, and tracking your token cascade covers the setup. No prompt content is needed for any alert below.
2. Set a baseline before you set a threshold
Collect at least 14 days of per-session and per-day totals. Use the median and the 90th percentile, not the mean, because one bad day drags the mean up and makes later spikes look normal. Re-compute the baseline weekly so a deliberate change in workload does not keep firing alerts. Keep weekdays and weekends separate if your usage differs.
3. Per-session versus per-day alerts
They catch different failures. A per-session cap is a circuit breaker: it fires within minutes and should stop the work. A per-day alert is an early warning: it fires after the fact and should open a conversation. With only a per-day alert, you learn about a loop the next morning, after the cost is spent.
| Alert | Signal | Starting point | Catches |
|---|---|---|---|
| Per-session token cap | Total tokens in one session | Hard stop at 2 times your p90 session | Runaway agent loops, accidental huge-file reads |
| Per-day spend or token trend | Daily total vs trailing 14-day median | Warn above 1.5 times the p90 day, page above 3 times p90 | Slow drift, new expensive workflow, broken cache |
| Cache reuse drop | cache_read per turn, plus fresh input per turn; cache hit rate as a companion | Warn when cache_read per turn falls below half its 14-day median, or cache hit rate drops 15 points below its 14-day median | Prefix changes that invalidate prompt caching, including total cache loss where the ratio is undefined |
| Fresh input per turn | Uncached input tokens per request | Warn when the median per-turn value reaches 2 times its 14-day median | Re-pasted context, tool output dumped into the prompt |
| Output-to-input stall | Output tokens per fresh input token over a window | Warn when a long session produces almost no output | Loops that spend input but never finish |
4. Watch cache hit rate separately
SigRank defines cache hit rate as cache_read / (cache_read + cache_write). When it falls, the same context is being rebuilt instead of reused. Anthropic's documentation prices cache reads at 0.1x base input for most models (lower for some newer ones) and 5-minute cache writes above base input, so a cache that stops matching raises cost without any change in what you asked the model to do (as of 2026-11-06; check the current multipliers). The ratio has a blind spot: if caching stops entirely, both cache_read and cache_write are zero and the ratio is undefined, and if the broken prefix is billed as fresh input the ratio can look unchanged. So also alert on cache_read per turn and fresh input per turn.
The usual causes are in the provider docs: a change to tool definitions or the system prompt, a timestamp or other per-request value placed before the cached section, or a gap longer than the cache lifetime (5 minutes by default). When the alert fires, diff the start of the prompt between a good request and a bad one. Our guide to reducing token waste covers the fixes.
5. Stop runaway agent loops
A loop is an agent that keeps calling the model without making progress. Three controls work together:
- Cap turns and tokens per session in the agent harness, so the loop ends on its own.
- Flag repeated identical tool calls, for example the same command run three times in a row.
- Alert when input per turn grows every turn while output stays flat; that pattern means context is piling up without producing work.
Route the alert somewhere a person sees it quickly, and make the message carry the session ID, the model, and the last few tool calls.
Tune after two weeks
Review every alert that fired. Raise thresholds that fired on normal work; lower the ones that fired late. Aim for few enough alerts that each one gets read. For tools that count and compare token usage, see token tracking tools and token cost tracking tools.
FAQ
- What is a good threshold for an LLM token usage spike alert?
- Start from your own baseline rather than a fixed number. A common starting point is to warn when a day exceeds 1.5 times the 90th percentile (p90) of the trailing 14 days and to page at 3 times p90, and to stop a session at 2 times the p90 session. Tune after two weeks of alerts. These multipliers are working heuristics, not measured standards; the right values depend on how variable your normal usage is.
- Should I alert per session or per day?
- Both. Per-session alerts catch a runaway agent loop within minutes, because a single session can burn a day of budget in an hour. Per-day alerts catch slow drift, such as a cache that stopped working or a new workflow that is simply expensive. Use a hard per-session cap as a circuit breaker and a per-day trend alert as the early warning.
- Why does a drop in cache hit rate cause a token spike?
- When the cached prefix stops matching, the same context is billed as fresh input or as a new cache write instead of a cheap cache read. Anthropic's documentation prices cache reads at a fraction of base input (0.1x for most models, lower for some newer ones, as of 2026-11-06) and 5-minute cache writes above base input, so a broken cache raises cost sharply even when your prompts have not grown. Check the current multipliers in the linked docs. Anything that changes the cached prefix, such as tool definitions, system prompt edits or a timestamp placed early in the prompt, can cause it. Note that the cache hit rate ratio alone can miss this: if caching stops entirely the ratio is undefined, so also watch cache_read and fresh input per turn.
- How do I detect a runaway agent loop?
- Look for sessions where the number of model calls or total tokens keeps climbing while output stays flat or repeats. Practical signals: more than a set number of calls with no new file changes, the same tool call repeated several times in a row, or input tokens per turn growing every turn without a matching increase in useful output. Cap turns and tokens per session so a loop stops itself.
- What data do I need to build token spike alerts?
- Per-request token counts split into fresh input, output, cache read and cache write, plus a session identifier and a timestamp. Provider APIs return these in the usage block of each response. For local coding agents, tools such as ccusage read the same counts from session logs. Prompt and response content is not needed.
Related: Cache Hit Rate · How to Read Your Token Cascade · Methodology