Diagnosing Abnormal LLM Inference Quota Consumption

    This article breaks down why LLM inference quotas can drop sharply even when usage patterns stay the same. It explains a practical cost model based on input and output tokens, prefix cache hit rates, and repeated full recomputation, then examines four common root causes: poor context auto-compaction settings, cache invalidation after compaction, compaction loops, and context stacking across multiple sub-agents. Readers will find observable monitoring metrics, step-by-step reproduction and isolation procedures, and optimization strategies to reduce wasted quota while awaiting vendor confirmation.

    1. The Symptom: A “Cliff-Edge” Drop in Quota Is Not an Illusion

    Over the past two days, many heavy users of AI coding tools have reported that, without any noticeable change in their normal usage intensity, the share of model inference quota consumed has jumped from roughly 20% to around 50%. Quota that normally supports several hours of interaction is now exhausted within twenty minutes. These reports share a common pattern: the use case, code scale, and number of interaction turns remain unchanged, yet the recorded consumption has multiplied.

    From an engineering perspective, this “same input, double the cost” behavior is usually not because the model itself has become more expensive. It is more likely that the context volume carried by each effective request and the amount of repeated computation have increased. To find the root cause, you need to break the cost of a single request into observable components.

    2. Cost Model: What Actually Makes a Request Expensive

    The industry generally agrees that billing and resource consumption for LLM inference are driven by a few core variables: input token count, output token count, whether the prefix cache is hit, and whether repeated full recomputation occurs. A simplified cost function helps illustrate this:

    1. Cost per request ≈ input tokens × input price × (1 - cache hit rate × cache discount)
    2. + output tokens × output price
    3. + overhead from extra calls such as compression or summarization

    This shows that what truly amplifies consumption is often not “what you asked,” but the context volume repeatedly carried behind each request, along with full recomputation caused by cache invalidation. The abnormal consumption patterns below fall into four frequent root causes.

    3. Deep Dive into Four Frequent Root Causes

    3.1 Poorly Configured Context Auto-Compaction

    When the session context approaches the window limit (for example, nearing the ~240K token range), the tool triggers auto-compaction, summarizing the conversation history to free up space. The problem is unreasonable compaction parameters: before compaction the context is about 240K–250K tokens, and after compaction it still retains 140K–160K tokens, freeing up very little space. This means the system pays the computational cost of compaction itself but gains almost no usable new space—a classic case of “high investment, low return.”

    3.2 Cache Hit Failure After Compaction

    In normal multi-turn conversations, the prefix stays stable, the cache can be hit at a high rate, and cost is significantly amortized. But once a compaction summary is inserted, the conversation prefix is rewritten and the existing cache chain breaks. The first request after compaction is nearly equivalent to a cold-start full recomputation. If the cache hit rate falls from a high level to a low one, a multiplied increase in overall consumption is an inevitable result.

    3.3 Compaction Loops (Compaction Storms)

    This is the most dangerous pattern. The threshold that triggers auto-compaction is about 244,800 tokens, yet after three consecutive compactions, the input of the next normal request is still as high as 241,860, 241,604, and 242,041 tokens—always hovering near the threshold and repeatedly triggering compaction. The system falls into a dead loop of “compact—still over limit—compact again,” where each cycle stacks compaction overhead and cache invalidation overhead, rapidly draining the quota.

    3.4 Context Stacking Across Multiple Sub-Tasks

    In a parallel mode of “one main agent plus multiple sub-agents,” if the main agent compacts a dozen or so times and each sub-agent compacts a dozen or so times, the total number of compactions in a single day can reach dozens. Each sub-agent maintains its own independent context, so the total volume is multiplied, and caches are hard to share between them, further driving up wasted consumption.

    4. Observable Monitoring Metrics

    To determine whether consumption is abnormal, it is recommended to continuously collect the following metrics and set up alerts:

    • Average input tokens and output tokens per request;
    • The trend curve of the prefix cache hit rate (a sharp drop is a strong signal);
    • The number of compaction triggers per unit time and the token difference before and after compaction;
    • Whether the input tokens of the first request after compaction still sit close to the threshold;
    • The context volume distribution of the main and sub-agents.
    1. Alert example (pseudo-rule):
    2. if cache hit rate drops > 40% compared to the previous period AND compactions per hour > 10:
    3. flag as "suspected compaction storm"

    5. Reproduction and Diagnosis Steps

    1. Fix the variables: Keep the task type, code repository scale, and number of interaction turns unchanged, and observe only the consumption curve to rule out “natural usage growth.”
    2. Capture compaction logs: Record the timestamp of each compaction, the tokens before and after compaction, and the input tokens of the first request after compaction.
    3. Check cache metrics: Compare the hit rate before and after compaction to confirm whether the cache chain is broken.
    4. Determine whether it is a loop: If the input tokens after compaction stay above 90% of the threshold continuously, it can be judged as a compaction loop.
    5. Isolate sub-tasks: Temporarily disable parallel sub-agents and observe whether consumption falls back, to confirm the stacking effect.

    6. Optimization and Avoidance Strategies

    • Adjust the compaction threshold and retention ratio: Make compaction actually free up enough space, avoiding “compacting with no effect.”
    • Keep the prefix stable: Place stable, unchanging system prompts and project conventions at the front to reduce cache invalidation caused by mid-conversation rewrites.
    • Suppress compaction loops: Set a minimum usable-space floor after compaction; if enough space cannot be freed, create a new session instead of compacting repeatedly.
    • Control the number of sub-agents and their context: Set an independent and streamlined context limit for each sub-task to avoid uncontrolled total volume.
    • Improve observability: Use logging services and monitoring alerts to establish baselines and anomaly detection for cache hit rate and compaction counts.

    7. The Boundary Between Vendor-Side and User-Side

    It should be stated objectively that such issues may stem from defects in the tool-side compaction and caching strategies, or may be related to platform-side risk-control or scheduling adjustments, and users cannot fully prove the cause on their own. The rational approach is to preserve log evidence, provide feedback through official channels, and wait for vendor confirmation and a fix, while using the optimization measures above to reduce your own losses in the meantime and avoid continuously “bleeding” quota before the problem is located. For enterprise scenarios, adopting a cloud-based solution that supports fine-grained usage auditing and quota management can help pinpoint the source of anomalies faster.