Abnormal Agent Quota Usage: Auditing Context Compaction and Metering
Similar reports of faster coding-agent quota burn after a point in time do not, by themselves, prove a metering defect. This article treats the issue as a cost audit: separate subscription quota from token billing, break usage into four multipliers, and use controlled comparisons to tell task growth, compaction thrash, cache misses, agent loops, and platform metering changes apart.
Community reports of coding agents consuming quota faster after a certain point share a few recurring symptoms: the task looks unchanged, yet weekly quota falls faster; a single session consumes close to ninety percent of the weekly quota; dozens of automatic context compactions happen in one day; the main agent and several sub-agents each trigger compaction; the retained context after compaction is still large, and the next request approaches the threshold again; cache-related metrics swing sharply; and some users also see extra safety prompts. Treating all of that as one “bug” is not rigorous. A better approach is a cost-ledger audit: first map the token consumption path, then decide whether the cause is a change in task structure, compaction thrash, cache invalidation, an agent loop, or a change in platform metering or default policy.
1. User reports are symptoms, not proof of a metering fault
A large volume of similar feedback shows that many people observed the same kind of experience. It does not automatically prove a single shared cause. Different users may be hitting four situations at once:
- The task itself became more complex—for example, a larger repository, larger tool results, or more concurrent sub-agents.
- Default configuration or session policy changed—for example, longer history retention or more aggressive tool use.
- Automatic context compaction is thrashing: repeated compaction and refill create extra consumption.
- Platform quota metering, cache discounts, or the statistical definition of usage changed.
On the user side, all four can look like “quota dropping in plain sight,” but the fixes are completely different. Deciding whether metering itself is defective requires reproducible controlled comparisons and complete usage records, not a date, a feeling, or community consensus alone.
2. Two ledgers: subscription quota is not a usage-based bill
Separate the accounts before debugging.
The first ledger is usage-based billing. It can be broken down by input tokens, output tokens, cache-hit tokens, request count, and rates. It is useful for relative analysis—for example, comparing token totals for the same task with compaction on and off.
The second ledger is the subscription quota. Subscription quotas for coding tools usually do not map one-to-one onto public usage-based line items. They may combine model, task type, invocation style, tool use, agent concurrency, and platform policy. Two requests with identical token counts can still deduct different amounts of subscription quota. Conversely, a rise in tokens does not necessarily deduct quota on the same linear scale.
Breaking tokens down in usage-based terms is a useful investigation framework, but it is not a direct conclusion about how subscription quota is metered. In engineering terms, use it to answer three questions: which turn the consumption happened on, whether it came mainly from input or output, and how much compaction and caching each added.
3. Cost is the product of four multipliers
3.1 Context tokens on a single request
An agent session does not send only the current question. Each turn may re-include:
- Conversation history
- Tool results, such as large file reads, version-control diffs, and log excerpts
- Project-level agent instruction files
- External tool lists and their parameter schemas
- Earlier plans, execution results, and error messages
Even if a turn adds only a few hundred tokens, a history of hundreds of thousands of tokens resent on every turn adds up quickly. Tool results are the quieter part: one full-file read, one complete log dump, or one large diff can contain thousands of tokens or more, and that content then becomes history for later turns.
3.2 Turns, tool loops, and sub-agent concurrency
Agent turns are not chat turns. One user request can include planning, file reads, tool calls, analysis, edits, tests, retries, verification, and a summary. Each step can be its own request.
If a failed tool call is retried, or the agent has no clear stop condition, a loop of “read file, run, error, read file again” is easy to form. Sub-agents can improve throughput, but they also multiply cost: each sub-agent has its own context, and if a sub-agent’s full execution log is returned to the main agent, the main agent’s input grows again. When the main agent and several sub-agents compact at the same time, costs stack rather than simply add.
3.3 Cache hits and cache invalidation
Long-context sessions usually rely on prefix caching to cut repeated cost. Caching works only if the prefix stays stable. If each turn dynamically inserts timestamps, random identifiers, highly variable tool results, or reordered tool schemas, the hit rate can fall.
Automatic compaction is especially sensitive to cache behavior: compaction rewrites the historical prefix. An old cache that could be reused may no longer hit, and the system has to reprocess the new summary plus recent context. A high cache-hit ratio is not automatically a problem. What matters is how many input tokens were uncached, how cache writes and reads are weighted, and whether compaction produced a large miss. Looking only at one hit ratio can lead to the opposite conclusion.
3.4 Extra cost of automatic context compaction
Compaction is not free. It typically includes:
- Sending near-threshold context into the compaction process
- Generating a summary or a structured retained result
- Carrying the summary, recent messages, and tool definitions on later requests
- Changing the cached prefix because the summary replaced history
One community pattern is worth watching: the trigger threshold is about 240,000 tokens, compaction retains 140,000 to 160,000 tokens, and the next ordinary request’s input is again close to 240,000 tokens. That means the headroom freed by compaction can be filled quickly by new tool results and fixed overhead. If the summary keeps too much, or tool results are too large, compaction becomes a loop of “just compacted, already near the threshold again.”
Worse, compaction can happen per agent. The main agent compacts once; several sub-agents each compact; sub-agent results return to the main agent and it grows again. The user sees “dozens of compactions in a day.” The platform pays the combined cost of compaction input, compaction output, cache invalidation, and later context replay.
4. Why the task “did not change” while quota did
“The task did not change” is often a subjective impression. The actual execution path may already have changed:
- Longer history is retained by default
- The agent leans toward more planning turns and tool calls
- Large file reads and log returns increased
- Sub-agent splits became more aggressive
- Compaction thresholds or retention policy changed
- Cache hit rate dropped
- Usage reporting is coarse, so several sub-agents or background calls appear as one deduction
- Reporting lag makes deductions look concentrated in a short window
Safety prompts and quota consumption should be investigated separately. An extra prompt means the policy layer may have run an additional check; that is not the same as a metering error. A metering anomaly can also occur with no safety prompt. The two can be related, but neither proves the other.
5. Build a ledger you can compare
Run the same fixed task before and after, and record:
- Session identifier, start time, and end time
- Model and parameter settings
- Number of main agents and sub-agents
- Per-turn input tokens, cache-hit tokens, uncached input tokens, and output tokens
- Estimated tool-result tokens
- Compaction count, tokens before compaction, and tokens after compaction
- Retry count and failed tool-call count
- Final quota deduction or subscription consumption
The pseudocode below is only for relative analysis. It is not a model of subscription quota:
def estimate_turn_cost(turn, input_weight, output_weight, cache_discount):uncached_input = max(0, turn.prompt_tokens - turn.cached_tokens)cost = uncached_input * input_weightcost += turn.cached_tokens * input_weight * cache_discountcost += turn.output_tokens * output_weightif turn.compaction:cost += turn.compaction_input * input_weightcost += turn.compaction_output * output_weightreturn cost
Add a compaction-thrash check:
def detect_compaction_thrash(session, threshold, max_compactions=3):recent = session.compactions[-max_compactions:]if len(recent) < max_compactions:return Falsefor item in recent:headroom = threshold - item.next_prompt_tokensif headroom > 0.15 * threshold:return Falsereturn True
If, after several consecutive compactions, the next turn’s input is still near the threshold, mark the issue as compaction thrash or context refill that is too fast—do not keep retrying blindly.
6. Practices that lower total cost and anomaly risk
First, inject less history. Long-running tasks should use stage summaries, external notes, and structured state instead of keeping the full conversation forever. Do not keep stuffing an entire large file back into context. Prefer paths, line ranges, diff summaries, and a few key excerpts.
Second, cap tool results. Put length limits on logs, test output, directory listings, and diffs. Parse first, then return. Deduplicate repeated content. The larger the tool result, the higher the context cost of every later turn.
Third, control what sub-agents return. Give them narrow tasks. Have them return a short conclusion, where the evidence is, and only the necessary excerpts—not the full execution log to the main agent.
Fourth, keep the cache prefix stable. Put fixed instructions, tool definitions, and parameter schemas at the front, and dynamic content at the end. Do not insert timestamps or random values into the system prompt. Keep tool order stable.
Fifth, bound compaction. After compaction, leave enough headroom. When compaction count exceeds a threshold and the next turn is still near the limit, pause, split the session, or move state to external memory instead of entering a compaction loop.
Sixth, set budgets and stop conditions. Limit maximum turns, maximum tool calls, per-session token budget, and retries. On repeated failure, the agent should fail explicitly and return rather than try forever.
7. When it is reasonable to suspect platform metering
Suspect the metering layer only after task, configuration, cache, and compaction factors have been ruled out. Useful criteria:
- The same prompt, the same tool configuration, and the same task produce roughly the same request count and client-observed tokens, but quota deduction rises significantly
- Sessions that never compacted also drop abnormally
- Request count or model in the usage record clearly does not match what actually ran
- A change in cache-hit behavior cannot explain the quota difference
- Controlled comparisons reproduce the gap repeatedly, and the provider’s usage records stay offset from the user-side bill
At that point, assemble a minimal reproduction: time range, task steps, model settings, session consumption summary, compaction count, sub-agent count, and the expected-versus-actual gap, then report it to the provider. Do not submit only “it feels faster,” and do not publish a conclusion without data.
Closing
Abnormal quota consumption is usually not a single-point failure. It is a systemic cost problem created by long context, tool calls, sub-agent concurrency, automatic compaction, and caching together. Community reports matter because they describe a real usage pain. Those reports prove that the symptom exists; they do not, by themselves, prove one shared metering defect. The more reliable path is to separate the two ledgers, break the four multipliers apart, build a comparable ledger, fix compaction thrash and cache misses first, and only then decide whether platform metering is at fault. For developers, better agent context control lowers quota use and also makes tasks more stable and easier to explain.
