The Biggest Agent Bottleneck: Why Inference Is Shifting from Compute to KV Cache
This article examines why agentic workloads are moving the primary inference bottleneck from raw compute to KV cache capacity, reuse, and scheduling. It walks through the execution flow of a typical agent task, summarizes four defining workload characteristics, and outlines the core challenges around memory capacity, cache reuse efficiency, and scheduling stability. It then proposes a three-layer evaluation framework covering cache, compute, and scheduling metrics, followed by representative optimization directions: tiered KV cache offloading, context parallelism with decode kernel optimization, and prefill scheduling pacing. The goal is a practical baseline for delivering high-throughput, low-latency inference for agents.
1. Introduction: Agentic Workloads Are Reshaping the Inference Bottleneck
Agent applications, exemplified by AI coding tools, are becoming one of the largest traffic sources for large language model inference. Unlike traditional single-turn question-and-answer chat, a single agent task typically goes through dozens of cycles of “model inference → tool call → inference again”: context accumulates with each round, and multiple subtasks may be spawned to run in parallel along the way. This article refers to this class of traffic as an agentic workload.
This type of workload pushes the focus of inference engines beyond a single question of “how fast can we compute” toward three more practical questions: whether the KV cache fits, how much historical context can be reused, and whether scheduling stays stable when traffic spikes and dips. This article first breaks down the full execution flow of an agent task and summarizes its workload characteristics and challenges. It then discusses how to systematically evaluate inference engines in agent scenarios. Finally, it presents several representative general-purpose optimization directions across three dimensions: memory, compute, and scheduling.
2. How an Agent Task Executes
Imagine a user types “help me implement a certain feature” into an AI coding tool. Internally, the system goes through roughly the following process:
- The user submits a prompt containing the system setup, tool definitions, and the user request. At this point, the context is about 45.7k tokens.
- First model inference: the model understands the request and decides to first explore the project, so it issues a tool call (for example, reading code or retrieving the directory structure).
- Second model inference: the context grows to about 48.4k tokens, which is all the history from the previous round plus a small amount of new content returned by the tool.
- Tool calls continue, for example starting to write code and run tests, with N similar “inference–call” cycles omitted in between.
- After several rounds, the context has grown to about 108.5k tokens.
- The main task fans out into multiple subtasks that proceed in parallel, while the main task itself enters a waiting state:
- Subtask one starts from about 10k tokens provided by the main task, calls tools to look up material, and grows to about 29.4k tokens.
- Subtask two also starts from about 10k tokens, calls tools to run verification, and grows to about 59.3k tokens.
- Both return their results after completion.
- After collecting all subtask results, the main task resumes inference and reaches about 141.5k tokens, which is the original 108.5k plus the new content returned by the subtasks.
Four key characteristics of agentic workloads can be distilled from this process:
- Long context that grows monotonically: it is normal for a single task’s context to grow from tens of thousands to over a hundred thousand tokens.
- Strong prefix reuse: the input to each inference round is almost a superset of the previous round’s input, with a highly overlapping prefix.
- Structured fan-out and aggregation: the main task spawns subtasks and then aggregates their results, forming a tree-shaped call topology.
- Polarized compute patterns: the prefill stage processes long context and is compute-intensive, while the decode stage generates token by token and is memory-access-intensive.
3. Core Challenges
3.1 Memory Capacity Pressure
Linear context growth means KV cache usage expands in step. As the number of concurrent tasks rises, memory quickly becomes a hard constraint, directly limiting how many tasks can run concurrently and how long a context can be supported.
3.2 Cache Reuse Efficiency
A highly overlapping prefix should yield a high reuse rate. However, if the cache is managed per request and lacks a sharing mechanism across rounds and subtasks, the repeated long prefix is recomputed again and again, wasting a large amount of compute.
3.3 Scheduling Stability
Agent traffic is clearly bursty: a single fan-out can instantly bring in multiple concurrent requests, and the completion of subtasks forms an aggregation peak. At the same time, mixing long prefills with short decodes can easily cause head-of-line blocking, amplifying latency jitter.
4. Evaluating Inference Engines for Agent Scenarios
Evaluating agentic workloads should not rely on single-request latency alone. Instead, metrics should be established at three levels:
- Cache dimension: prefix cache hit rate, cache residency duration, and the context scale that can be held per unit of memory.
- Compute dimension: time to first token (TTFT), time per output token (TPOT), and long-context prefill throughput.
- Scheduling dimension: throughput stability under high-concurrency fan-out, P99 latency, and queueing latency during the aggregation phase.
For the evaluation method, it is recommended to use a multi-round workload model with fan-out that closely mirrors real traffic, rather than isolated short requests, so that cache reuse and scheduling jitter are reflected accurately.
5. Optimization Directions Across Three Dimensions
5.1 Memory Dimension: Tiered KV Cache Offloading
Offloading cold KV cache from memory to main memory or even faster storage tiers, and migrating it back when needed, can significantly expand the context scale and concurrency that can be supported. A general approach is as follows:
Hot data (memory) <-> Warm data (main memory) <-> Cold data (high-speed storage)On-demand migration back + reuse on prefix hit
In engineering practice, attention should be paid to offload bandwidth, migration-back latency, and hit determination, so that the gains from offloading are not offset by migration-back overhead.
5.2 Compute Dimension: Context Parallelism and Decode Kernel Optimization
- Context Parallelism: split an ultra-long context across multiple compute units to process prefill collaboratively, reducing per-device memory and compute pressure and shortening long-context TTFT.
- Decode Kernel Optimization (Mono Decode Kernel): for the memory-access-intensive nature of the decode stage, use fusion and specialized kernels to reduce memory access and launch overhead, improving per-token generation efficiency.
5.3 Scheduling Dimension: Prefill Scheduling Pacing
By controlling the number of prefill requests admitted in each scheduling cycle (that is, the prefill scheduling interval), a balance can be struck between long prefills and decodes, easing head-of-line blocking and smoothing P99 latency. Illustrative logic:
Each scheduling cycle:Admit a number of prefill requests within budgetPrioritize remaining compute for ongoing decodesAvoid long prefills monopolizing resources and starving decodes
6. Conclusion
The essence of agentic workloads is that they shift the core tension of the inference system from “compute” to “cache and scheduling.” Whoever can fit the KV cache, reuse it well, and keep scheduling stable under fluctuating traffic will be able to provide high-throughput, low-latency inference services in the agent era. The three optimization layers above—memory, compute, and scheduling—can serve as a general practice baseline for building such capabilities, with specific parameters and behaviors tuned continuously against actual workloads.
