arXiv:2610.22863cs.DCOct 2026Cited by 1 paper on PaperVantage

Manuscript Offprint

arXiv:2610.22863

Understanding KV Residency in Production-Scale Agentic LLM Workloads

Mayank Arya, Agrim Bari, Anjaly Parayil, Yogesh Simmhan, Renee St. Amant, Victor Rühle, Saravan Rajmohan

Mayank Arya

Indian Institute of Science (IISc)

Anjaly Parayil

Microsoft M365 Research

Agrim Bari

Microsoft M365 Research

Yogesh Simmhan

Indian Institute of Science (IISc)

Renee St. Amant

Microsoft M365 Research

Victor Rühle

Microsoft M365 Research

Saravan Rajmohan

Microsoft M365 Research

Email: mayankarya@iisc.ac.in; agrimbari@microsoft.com; aparayil@microsoft.com; simmhan@iisc.ac.in

Abstract

Agentic large language model (LLM) applications turn a single user request into a sequence of model and tool calls over a growing context. Retaining the key-value (KV) state computed for this context in GPU memory allows subsequent calls to reuse it rather than recompute it. However, retaining KV state across a serving fleet can require substantial GPU memory. We characterize four production Microsoft M365 workload traces, namely Deep Research, Enterprise Assistant, Coding Agent, and Enterprise Chat, spanning more than 121 million model calls. Agentic applications issue most calls within a session, and each call re-reads the growing context. In Deep Research, the application issues 89% of model calls. Sessions have a median of 13 model calls, while Enterprise Chat, our lower-agency reference, has 333. The median context grows from approximately 10K tokens to 68K tokens by the 30th30^{th} call. About 80% of context tokens are served from the prefix cache, and a predictable class of models accounts for 67% of call-context KV.

This reusable KV state is large and remains idle for most of its lifetime. Since the production models are confidential, we use the public Llama-2-70B KV layout, with grouped-query attention and 16-bit values, to estimate the memory demand consistently across models. Under this assumption, the KV state of a single 99th-percentile Deep Research session exceeds the 80 GB high-bandwidth memory (HBM) capacity of an NVIDIA H100 GPU. Retaining the KV state of all live sessions at their peak, which we term the hold-all-live ceiling, requires an estimated 501.8 TB of GPU HBM. However, model inference occupies only 5.6% of the time for which this state is retained. Enterprise Chat has smaller sessions but approximately 349K concurrent live sessions, resulting in a similar capacity challenge.

Trace-driven replay shows that an idle cap of one hour reduces the hold-all-live ceiling by 3.6×3.6\times, while increasing the fraction of calls that recompute their context from 4.07% to 4.53%. However, eviction alone is insufficient under tighter memory budgets. With a pooled budget equal to one tenth of the busiest hour's no-eviction demand, least recently used (LRU) eviction causes 63% of Deep Research calls to recompute their context. Furthest-next-use (FNU), a clairvoyant policy based on Belady's rule, reduces this to 31%. Multi-resolution retention (MRR) instead demotes the LRU session's KV state to an int4 representation within the same memory budget. MRR reduces the recomputation rate to 13.6%, 2.3×2.3\times lower than FNU, despite selecting sessions using recency alone.

Placement imposes a separate limit on reuse. When the next call to the same model reaches a different deployment within the region, cached-context reuse drops from 89% to 29%. A Deep Research session accesses 4.5 deployments on average. Treating KV state as local to a deployment increases the first-touch floor, the fraction of calls that recompute their context even with unlimited memory, from 5.4% to 20.2%. Additional memory and better eviction cannot reduce this floor.

These findings motivate retention mechanisms that change the representation of KV state, together with deployment-aware routing or migration. Since the production traces cannot be shared, we plan to release AgenticTraceSim, a parametric trace generator, and a residency replay framework for reproducible counterfactual studies.

Keywords: Large language model serving, agentic AI, KV cache, prefix caching, KV reuse, KV working set, KV cache residency, GPU memory capacity, fleet provisioning, deployment-aware routing, workload characterization

1 Introduction

Production LLM serving is shifting from individual requests to persistent, tool-interleaved sessions. In conventional chat, a user request opens a turn: the serving system performs a short sequence of model and optional tool calls, and control returns to the user. In an agentic workload, the request that opens a turn initiates a longer internal loop in which an orchestrator (e.g., one following the ReAct or Magentic pattern [58, 11]) repeatedly invokes models and tools, appends their results, and decides when the task is complete [66, 60, 28]. A session is a user's ongoing interaction with one application: a sequence of one or more turns that share a session identifier, together with the context they accumulate (Section 2.2 defines calls, turns, and sessions precisely).

This distinction changes the state that an LLM serving system must manage. Within a turn, a chat application typically returns control to the user after a short orchestration path, whereas an agentic application may re-enter the model many times without human input (Figure 1); a session repeats this loop once per turn. Each model call first prefills its input context, computing the attention keys and values of every context token in a Key-Value (KV) cache [20], and then decodes output tokens one at a time. Keeping reusable KV resident in GPU memory lets a later call skip prefill over a context prefix that an earlier call already processed, so the retained state remains valuable across otherwise idle intervals. Serving must therefore manage the size, lifetime, and placement of a session's evolving KV working set, in addition to scheduling the prefill and decode phases of individual model calls.

Agentic applications are emerging as a substantial component of datacenter LLM workloads, but their long-running control loops create KV residency and placement demands that request-level measurements do not capture. Recent studies (TraceLab [66], the GitHub Copilot study [28], and the ReAct study [60]) show that agents repeatedly invoke models and tools, carry growing contexts, and produce comparatively short outputs. None exposes the serving deployment selected for each call, and only the Copilot study operates at production scale, for a single coding workload and at the granularity of logical model endpoints. At hyperscaler scale, even modest errors in estimating prefix reuse, KV residency lifetime, or placement locality can translate into terabytes of excess GPU memory or extensive context reconstruction.

We address these gaps using four production traces from Microsoft M365. Deep Research

(RESEARCH), an agent that answers a request through a long loop of model and enterprise-search tool calls; Enterprise Assistant (ASSIST), a single-model productivity assistant; and Coding Agent (CODE). The fourth, Enterprise Chat (CHAT), also invokes tools, but its internal loops are much shorter, so it serves as the lower-agency reference (Section 2.4). Together, the traces contain more than 121 million model calls. The primary agentic trace, RESEARCH, contains 17M model calls in 691k sessions over eight days in June 2026; CHAT contains 104M model calls in 13.2M sessions over 24 hours in July 2026 (Table 2); a session averages 2.62 user turns in RESEARCH and 2.29 in CHAT. Unlike prior traces, our telemetry combines production-scale enterprise workloads with session structure, token accounting, model identity, and, for three workloads, the serving region and deployment selected for each call.

We follow an agentic session’s KV state through five questions, from how the state accumulates and is reused, to how memory capacity and deployment placement affect its residency.

Q1. How agentic is each workload? Orchestration metrics place the traces on a spectrum of agency (Section 2).

Q2. Why does KV matter? The model-tool loop makes agentic sessions deep: RESEARCH has a median session depth of 13 model calls and a P99 of 160, compared with 3 and 52 for CHAT. Context keeps growing across these calls, and the three agentic workloads achieve aggregate KV reuse of 0.50–0.80, compared with 0.27 for CHAT, although all four have median within-session idle gaps of 6–10 s (CODE: tool-execution cadence; Figure 2; Sections 3.5 and 4.3). These measurements show that the agentic workloads carry substantially more reusable KV state across idle intervals with similar median durations (Section 3).

Q3. Why not keep all of it? Under the reference fp16 grouped-query-attention (GQA) KV representation (Section 2.3), a single session's KV can approach the memory of an entire GPU; holding every live RESEARCH session at its peak working set would require an estimated 501.8 TB; the state sits idle across heavy-tailed gaps; and its reuse is associated with staying on the serving endpoint, which we call a deployment, that built it (Section 4).

Q4. What can be done? Reclaiming state after one idle hour lowers the RESEARCH hold-all-live ceiling from 501.8 to 140.8 TB (Section 5.1), and replaying residency under constrained memory separates recomputation caused by insufficient GPU memory from that caused by routing when KV is deployment-local, and quantifies the potential value of affinity-aware routing [45, 38, 29] and multi-resolution KV retention [32, 17, 30, 57] (Section 5).

Q5. How can others study this? Because the traces cannot be released, we plan to release a parametric trace generator (Section 6).

Contributions. This operational systems article makes five contributions, one per question.

  1. We present a production-scale characterization of four Microsoft M365 workloads spanning three agentic applications and one enterprise-chat workload, and compare their agency where the telemetry permits. The traces contain more than 121 million model calls and expose session, token, and model structure and, for three workloads, deployment structure (Section 2).

  2. We characterize how persistent model-tool loops shape session depth, context growth, and KV reuse. Context continues growing across deep sessions, reuse is bimodal at the call level, and in RESEARCH call-context KV concentrates in a predictable model class: the heavyweight SPINE class, which carries the long-running context, holds 67% of call-context KV bytes but only 32% of uncached-context tokens and has a self-transition probability of 0.97 (Section 3).

  3. We show why retaining every session's KV is a fleet-wide GPU-memory capacity problem.

Short orchestration path

Figure

Mean: 2.49 model calls/turn

(a) Chat turn

Repeated model-tool loop

Figure

Mean: 9.38 model calls/turn

(b) Agentic turn

Figure 1: Control flow within one user turn. A turn runs from a user request until control returns to the user; a session is the sequence of turns that share a session identifier, so this loop repeats once per turn. In-figure means are model calls per user turn (total model calls divided by total user turns), as in Table 2.

Figure

Figure 2: Aggregate KV reuse R (Eq. 2) versus the median within-session idle gap (time between consecutive model calls, intra- and inter-turn gaps pooled) for the four workloads; the shaded band spans 6–10 s. CODE's R uses its session-cumulative cache_read accounting, and its idle value is its median tool-execution cadence; the other traces use provider-reported cached tokens.

Under the reference KV representation, a single P99 RESEARCH session requires 81.6 GiB, exceeding the 80 GB high-bandwidth memory (HBM) of an NVIDIA H100 GPU, and holding every live RESEARCH session at its peak lifetime working set requires an estimated 501.8 TB at the exact peak. In RESEARCH, mean same-model reuse is also associated with deployment continuity: 88.9% when consecutive calls remain on one deployment versus 29.0% after a same-model deployment change within the region (Section 4).

  1. We identify two distinct sources of KV recomputation: eviction under limited memory and unavailability under deployment-local placement. At a pooled memory budget of 10% of the busiest-hour current-context peak (the KV that hour needs with no eviction), even clairvoyant eviction by Belady's furthest-next-use rule (FNU) leaves 31.1% of RESEARCH calls to recompute their context, while int4 multi-resolution retention (MRR), which keeps an evicted session's KV as a 4-bit copy instead of discarding it, reduces this call-level miss rate to 13.6%. Separately, modeling KV as deployment-local raises the first-touch floor, the share of calls that miss even with unlimited memory, from 5.4% to 20.2%, motivating both recoverable KV retention and affinity-aware routing (Section 5).

  2. Because the production telemetry cannot be released without risking client confidentiality, we plan to release AgenticTraceSim, a parametric trace generator, together with a residency replay; the generator reproduces the principal RESEARCH distributions, their dependencies, and the downstream policy ordering without exposing production events (Section 6).

References (63)