arXiv(opens in a new tab)cs.OSSep 2026Cited by 2 papers on PaperVantage

Manuscript Offprint

arXiv:2609.39819

Capture the lifecycle: KV Cache management in ReAct Agents with KVTether

Kaihua Fu, Yukun Zhou, Chaokun Chang, Yinghao Yu, Luping Wang, Guodong Yang, Jiuchen Shi, Quan Chen, Wei Wang

Abstract

Efficient serving of long-context reasoning-and-acting (ReAct) agents relies on KV cache reuse to reduce large language model (LLM) prefill latency and monetary cost. However, a semantic gap exists between agent harnesses and the underlying serving stack. Through context mutation, tool execution, and subagent coordination, context messages may become actively engaged, permanently discarded, and temporarily unused, while the serving stack only observes accesses to the corresponding KV cache. This lifecycle blindness prevents recency-only policies such as LRU from reclaiming dead KV promptly and from preserving older KV that will be reused sooner than newer entries.

We present KVTether, a lifecycle-aware KV cache management framework for ReAct agents. By tracing semantic primitives embedded in agent harnesses, KVTether captures runtime lifecycle semantics during highly dynamic execution. KVTether then translates message-level semantics into KV-level lifecycle states and uses these states to drive state-prioritized cache management without exposing physical complexities to agent harnesses. After reclaiming dead KV, KVTether preferentially preserves live-but-idle KV that is waiting for reuse, reducing premature eviction before reuse. Across agent benchmarks and production workloads, KVTether reduces end-to-end request latency by up to 26.3% and 17.4% relative to LMCache and MORI, respectively, and lowers estimated task cost by 40.0% and 33.2% on average.

1 Introduction

Large language model (LLM) applications are evolving from interactive chatbots to autonomous agents. Mainstream agents such as Claude Code [2], Codex [23], OpenClaw [26], and Hermes [20] execute user requests through a reasoning-and-acting (ReAct) loop [34] interleaving LLM inference with tool calls. Over tens to hundreds of ReAct turns, a request can accumulate hundreds of thousands of tokens; for example, a Codex request can reach a 258K-token context. KV cache reuse is essential to avoid repeated prefill of these long contexts [8], reducing inference latency and cost. Yet retaining KV is costly: in GLM-4.7 [36], a 258K-token context requires 93GB of KV cache. Efficient KV-cache management is therefore essential for practical ReAct-agent serving.

Figure

Figure 1. An example of message lifecycle changes across three LLM calls. Within each context, long-term messages are retained for continued reuse across calls; short-term messages remain reusable until removed or replaced; temporary messages expire after the current call.

ReAct agents, however, expose a fundamental semantic gap between the application layer and the underlying serving stack. At the application layer, the agent harness manages contexts through message-level operations [37] such as append, replace, remove, fork, and one-shot construction, which define the logical lifecycle of messages: how long they remain reusable within each context (Figure 1). The LLM inference layer (e.g., vLLM [15] and SGLang [39]) translates these contexts into token sequences, from which the KV-cache storage layer (e.g., MoonCake Store [28] and LM-Cache [7]) observes only cache pages, shared prefixes, and access events. As a result, physical KV residency can diverge from the logical lifecycles of source messages: the storage layer cannot tell whether a cached KV span is logically live, explicitly retained, temporarily waiting, or already dead.

Our analysis of two production traces from a large cloud provider and a widely used agent benchmark reveals two common inefficiencies caused by this lack of lifecycle visibility ( §2.4§2.4). First, KV can remain physically resident as zombie KV after its logical lifetime ends. For example, after a compaction subagent replaces a long history with a summary, both the discarded history and the one-shot compaction context are logically dead, yet their KV may persist until passive eviction. Our replay shows that zombie KV can occupy up to 36.3% of LMCache's capacity. Second, recency-only policies such as LRU can misorder live KV. Across the three workloads, 71.0–95.0% of LRU evictions are wrong-direction: admitted KV is needed later than the resident KV it displaces. This happens because recently produced KV in ReAct agents often awaits tool execution, scheduling, or subagent coordination rather than being closest to reuse. Both inefficiencies arise because the serving stack cannot distinguish dead from live KV or waiting from cold KV.

These observations motivate lifecycle-aware agent serving, which requires exposing lifecycle information to the serving stack as it is generated. Prior works on agentic workflows [5, 38] infer KV importance from predefined workflow structures [11, 22, 29] or execution histories, but this is insufficient for ReAct agents. Their execution topology is created at runtime through context mutations, tool results, and sub-agent decisions rather than by a stable structure visible in advance; in one industrial trace, the fraction of LLM rounds executed by sub-agents ranges from 1.6% to 86.5% across requests (§2.2). More fundamentally, lifecycle-defining events such as message replacement, removal, one-shot construction, and retention exist only in the harness's message-level context management, so lower layers cannot infer how KV should track application-level context changes or be retained for future reuse. ReAct-agent serving therefore requires lifecycle events to be exported from the application layer via runtime tracing and in-harness integration, rather than inferred downstream.

Making such lifecycle export practical is challenging for three reasons. (1) Diverse agent harnesses. Different agents, and even different subagents within one agent, may realize message-level context composition through incremental appends, prompt rebuilding, selective history carry-over, or one-off contexts, so ad hoc harness-side hooks quickly become brittle and hard to generalize. Practical lifecycle export therefore requires a harness-side integration interface that captures common context-management semantics across diverse harness behaviors. (2) Cross-layer complexity. Lifecycle information originates at the application layer, while KV management operates on physical objects such as token prefixes and cache pages. The goal is to bridge these layers without requiring application developers to reason about paging, prefix organization, or eviction timing; otherwise the lifecycle-export mechanism merely shifts KV-management complexity upward [12]. (3) Uncertain reuse intervals. Even after lifecycle events are captured and dead KV can be identified, live-but-idle KV remains hard to manage because their reuse intervals vary with tool behavior, LLM decisions, and deployment conditions [6]. These dynamics motivate robust KV management under runtime uncertainty, without relying on precise reuse prediction [16, 32, 33].

In this paper, we present KVTether, a lifecycle-aware KV-cache management framework for ReAct agents that exports message-level lifecycle semantics from the harness to the serving stack. KVTether comprises three design modules that work as a pipeline from semantic export to cache control. (1) Semantic primitive model (§4). KVTether places lifecycle export at the message-operation level, which matches how agent harnesses already compose and revise contexts. Developers use a small set of message-level primitives directly in existing context-management code, and KVTether captures lifecycle events automatically from those operations. These exported events provide a common semantic interface across diverse harness behaviors and serve as the input to KVTether's lifecycle manager. (2) Event-driven lifecycle manager (§5). KVTether uses an event-driven manager to translate exported message-level events into KV lifecycle states as cache action signals. It bridges the gap between message lists at the application layer and tokenized prefixes and cache pages in the serving stack. This design preserves precise KV control while keeping physical details transparent to the application layer. (3) State-guided KV cache engine (§6). Guided by the lifecycle states produced by the manager, KVTether's KV cache engine first reclaims space from dead KV, thereby confining the remaining uncertainty to live-but-idle KV. The further optimization is built upon a key observation that, when limited cache capacity forces space competition, newly used KV is often less urgent to retain than older live KV, as the execution of tools or subagents is not instantaneous. KVTether exploits this directional bias with MRU (most-recently-used) as a straightforward realization, mitigating wrong-direction evictions without relying on precise reuse prediction.

We evaluate KVTether on agent benchmarks and production traces from a large cloud provider, using 12 Nvidia GB200 GPUs across three nodes (§8). We compare against LMCache [7], a strong semantic-blind KV cache, and MORI [33], an agent-aware baseline that predicts reuse from inferred request idleness. Relative to LMCache and MORI, KVTether lowers estimated task pricing by 40.0% and 33.2% on average and end-to-end request latency by up to 26.3% and 17.4%, respectively. To assess the semantic primitive model's ease of adoption, we integrate KVTether into six agent harnesses with only 26–216 lines of integration code per harness.

References (41)