07.01 · Concept · Free
The Agent Workload
Describe the shape of agent traffic: long multi-turn trajectories, input sequences an order of magnitude larger than the output, near-total prefix overlap between turns. Name which specific assumptions from modules 3 and 4 stop holding.
Curated for this lesson
Serving Agents
The Agent Workload
The speaker explains that in agent conversations 'you have to send the full 51k tokens to the LLM,' then 'the LLM is going to respond... with probably another 3k tokens,' and on the next turn 'you resend the entire transcript,' so traffic has huge repeated input prefixes rather than independent short prompts.
Agent traffic is a growing sequence of LLM calls over the same transcript, with each turn mostly repeating the previous prompt and appending a small delta. The workload is input-heavy, prefix-heavy, and tool-paced, so serving is dominated by KV locality, prefix reuse, and cache-aware scheduling rather than ordinary decode batching.
What this lesson answers
- why agent workloads are different from chat serving
- how prefix overlap changes LLM inference scheduling
- when decode optimisation matters for agent serving
Notes
Agent serving is the regime where one logical user request becomes a trajectory of LLM calls over a growing transcript, tool results, retrieved documents, and scratch state. For turn , the prompt is usually , where is the system/developer prefix, are prior model messages and are observations from tools. The important quantity is not request count but prefix overlap: , often above for ReAct-style agents because each turn appends a small delta to a long transcript. The input/output ratio also flips: can be -, so the workload is dominated by prefill and prefix lookup rather than by long autoregressive decode. This is the traffic shape that invalidates the ordinary chat-serving picture used for single-turn prompts with modest context and little cross-request sharing.
A concrete H100 example shows why this matters. Take a 70B FP16 model on an 80GB H100 with TB/s HBM bandwidth, grouped-query attention with KV heads and head dim , and assume layers. The KV cache footprint per token is bytes bytes, about KiB/token. A k-token agent transcript therefore has about GB of KV. If the next agent step appends only new tokens before generating tokens, recomputing the whole prompt costs prefill over tokens, while exact prefix reuse prefills only . Even ignoring FLOPs and looking only at KV residency, the cached prefix is GB that must be retained or paged, not recomputed. This is why PagedAttention from the vLLM paper and automatic prefix caching in vLLM, SGLang’s RadixAttention paper, and TensorRT-LLM’s KV cache reuse features are central to agent serving rather than optional latency polish.
The first assumption from a decode-centric module that stops holding is that steady-state generation is the bottleneck and prefill is an amortized setup phase. For normal chat, one might model per-token decode bandwidth as roughly and optimize batching around many requests producing one token each. In an agent loop, the expensive event is often “same 30k tokens plus a 200-token observation, again,” and the useful batch contains heterogeneous prefills, prefix-cache hits, cache misses, tool-delayed resumes, and short decodes. FlashAttention, from Dao et al., still matters inside prefill because it reduces HBM traffic for attention, but it does not by itself exploit that and are nearly identical. PagedAttention’s block table, SGLang’s radix tree over token prefixes, TensorRT-LLM’s paged KV cache, NVIDIA Dynamo’s disaggregated serving stack, and llm-d’s Kubernetes-native inference scheduling are responses to this changed bottleneck: route and place requests so the already-materialized prefix is on the worker that needs it.
The second broken assumption is that requests are independent samples from a prompt distribution. Agent turns are causally linked, externally paced by tools, and cache-affine: moving turn to a different GPU can turn a -token incremental prefill into a k-token full prefill or a multi-GB KV transfer. With the numbers above, transferring the GB prefix KV over a GB/s NVLink path has a lower bound of ms, while over a GB/s PCIe path it is ms before software overheads; recomputing on an H100 may also be costly but can beat remote fetch if the link is weak or the prefix is cold. This is the serving problem targeted by prefill/decode disaggregation and cache-aware routing in systems such as NVIDIA Dynamo and llm-d, while vLLM and TensorRT-LLM expose the underlying paged-cache machinery. The scheduler’s unit becomes a trajectory with locality constraints, not an isolated request that can be freely load-balanced to the shortest queue.
The third assumption that stops holding is that batching similar decode lengths is the main lever for utilization. Agent traffic has bursty fan-out, tool gaps, and tiny generations: a planner may emit tokens, call search, append a k-token page, emit tokens, call Python, then append a traceback. Large continuous batches can be poisoned by long prefills arriving in the middle, while pure decode workers can starve during tool waits. Speculative decoding with EAGLE, from the EAGLE paper on feature-level extrapolation for lossless acceleration, helps only on the generation slices; if the trajectory spends of GPU time in uncached prefill or cache migration, a decode speedup caps end-to-end gain at . Conversely, when prefix hits are high and each turn emits hundreds of tokens, EAGLE or TensorRT-LLM speculative decoding can again matter. The workload mix, not the model alone, decides whether decode optimizations are visible in user latency.
Prefix caching and cache-affine serving also have sharp failure regimes. They stop helping when prompts are not byte/token identical after the shared prefix: timestamps, randomized tool IDs, nondeterministic JSON key order, per-turn retrieval inserted near the beginning, or changing system instructions can reduce enough that the radix or hash cache misses. They can make throughput worse when memory reserved for cold prefixes evicts hot active KV, when multi-tenant isolation prevents sharing, or when a scheduler pins trajectories to overloaded GPUs to preserve locality while idle GPUs sit elsewhere. For the 70B example, an 80GB H100 cannot hold model weights of about GB in FP16 on one device, so tensor parallelism is mandatory; the GB prefix KV is then sharded across ranks, and cache movement becomes a collective placement problem rather than a local map lookup. The agent-serving lesson is therefore specific: long multi-turn trajectories, input-heavy turns, and near-total prefix overlap break the independent, decode-heavy, freely batchable assumptions, replacing them with KV locality, prefix identity, and tool-paced scheduling as first-order constraints.
References
Common questions
- Why are agent workloads hard to serve efficiently?
- An agent request is not one prompt followed by one answer. It becomes a chain of calls where the prompt keeps growing with earlier messages, tool outputs, retrieved content, and scratch state. Most of each new prompt is identical to the previous one, so recomputing or moving that prefix can dominate latency and capacity.
- What assumption from normal chat serving breaks for agents?
- The main broken assumption is that requests are independent and can be freely load-balanced. Agent turns belong to a trajectory and are cache-affine: the next turn is much cheaper if it lands where the previous prefix KV already exists. The scheduler must care about locality, not just the shortest queue.
- Does speculative decoding help agent latency?
- Speculative decoding helps only during generation. Many agent turns spend most of their cost in prefill, prefix lookup, cache movement, or waiting around tool calls. If the generated answers are short and the repeated inputs are large, decode speedups may barely move end-to-end latency.
Short definition: what is Agent Workload?
