← Back to blog

Article · AI Architecture

KV cache routing: optimizing agentic AI infrastructure

KV cache routing and PD disaggregation solve the latency and cost of scaling agentic AI. Learn how prefix-aware routing keeps production agents fast and cheap.

KV cache routing is a prefix-aware scheduling technique that sends each agent request to the GPU pod already holding its cached context, instead of rebuilding that context from scratch. In multi-turn agentic workloads it can cut time-to-first-token from roughly 3 seconds to under 1 second, and because cached tokens can cost up to 10x less than fresh ones, it protects the token budget as sessions scale.

The industry is navigating a fundamental inflection point, moving from the era of classic LLM inference to the agentic era. While standard chat interactions were once the benchmark for success, real-world agentic workloads - such as autonomous coding assistants or complex multi-step workflow automation - are breaking the core assumptions of traditional model serving. For operations leaders and CTOs, this shift introduces a chaotic reality where sanitized benchmarks no longer reflect production performance. To bridge the gap, organizations must adopt sophisticated techniques like KV cache routing and pre-fill/decode disaggregation to manage the volatility of high-context, multi-turn AI systems.

Traditional LLM serving was designed for short, predictable interactions. Agentic workloads are the opposite - defined by extreme multi-turn sessions, sometimes reaching 3,000+ turns, and massive input-to-output (I/O) ratios that frequently exceed 100:1. These patterns create a management nightmare for standard Kubernetes deployments. When an agent frequently reuses system prompts or tool definitions, the economic and performance stakes rise significantly. In fact, research into model pricing, such as Anthropic's API structure, shows a 10x cost difference between cached and non-cached tokens. Failing to maintain cache locality isn't just a technical lag - it is a direct drain on the corporate token balance sheet, a problem we examined in the hidden crisis of AI token spend.

The hidden physics of phase interference in LLM execution

To understand why agentic workloads require a new architectural approach, one must first look at the underlying physics of how large language models (LLMs) execute tasks on hardware. Every inference request goes through two distinct phases: pre-fill and decode. The pre-fill phase is compute-heavy; it processes the initial prompt, builds the Key-Value (KV) cache, and thrives on high FLOPs and large batch parallelism. The decode phase is the opposite - it generates one token at a time, making it memory bandwidth-hungry and highly sensitive to latency.

In a standard, aggregated serving environment, a single GPU pod handles both phases simultaneously. This leads to a phenomenon known as phase interference. When a sudden influx of long pre-fill prompts hits a system, it can completely stall the ongoing decode process for other users. For an operator watching a streaming agent output, this manifests as jitter or long pauses in text generation. In the context of a mission-critical sales or support agent, this lack of smoothness destroys the user experience and undermines the reliability of the system.

Managing this interference requires moving beyond basic load balancing. Traditional round-robin scheduling fails because it doesn't account for what is already stored in a GPU's memory. If a router sends a request to a pod that doesn't have the relevant system prompt cached, the system must rebuild that cache from scratch, wasting time and compute resources. This is where the transition to a specialized agentic AI infrastructure becomes mandatory for scaling organizations.

KV cache routing: solving the 10x cost and latency problem

KV cache routing, or prefix-aware routing, is the first line of defense against the inefficiencies of agentic AI. This technique involves an intelligent control plane - such as the router found in the LLMD framework - that evaluates the state of every pod in a cluster before sending a request. Instead of just looking at which pod has the lowest CPU usage, the router uses an Endpoint Picker Plugin (EPP) to score pods based on KV cache locality and load criteria.

When an agentic system is running, the router constantly probes pods for their prefix cache availability. If a specific pod already holds the cache for a 10,000-token system prompt, the router will prioritize sending subsequent turns of that conversation to the same pod. This process, often referred to as session pinning, ensures that the context persists exactly where it is needed.

<!-- INFOGRAPHIC: KV cache routing versus round-robin - a prefix-aware router inspecting each GPU pod's cached prefix and pinning a multi-turn session to the pod that already holds its system prompt, cutting time-to-first-token from 3s to under 1s, versus round-robin scattering requests and forcing cache rebuilds -->

Research and demos involving these routing strategies show dramatic results. In multi-turn interactions, reusing the KV cache can reduce the time-to-first-token (TTFT) from 3 seconds down to 1 second or less. Because the system prompt and tool definitions are often the largest part of the context in agentic workflows, the cache hit rate in optimized environments often exceeds 90%. By ensuring these hits occur on the correct hardware, organizations can effectively bypass the most expensive and time-consuming parts of the inference cycle.

Pre-fill and decode disaggregation: when to split your stack

While KV cache routing improves the start of an interaction, pre-fill/decode (PD) disaggregation addresses the stability of the entire session. This architectural pattern involves splitting the pre-fill and decode tasks into independently scalable inference pools. In a PD deployment, a pre-fill worker processes the initial prompt and constructs the metadata, which is then transferred across a high-speed network fabric to a dedicated decode worker.

This separation allows each pool to be optimized for its specific task. Pre-fill pods can be configured for maximum throughput, while decode pods are tuned for the lowest possible inter-token latency (ITL). The impact on performance is significant - experimental results on large models like GPT-J 120B show that disaggregated deployments can achieve P99 inter-token latencies that are nearly 9x better than aggregated serving. For a user, this means the difference between 900ms of jitter and a smooth, 100ms stream of responses.

However, PD disaggregation is not a magic bullet for every scenario. It introduces complexity, particularly the need for an advanced network fabric like RDMA or RoCE to support the transfer of KV caches between pods. Organizations should consider PD disaggregation if they meet specific criteria:

  • Long contexts: High input-to-output sequence ratios where pre-fills are massive.
  • Large models: Models that require rich parallelism (tensor or expert parallelism).
  • Strict ITL requirements: When the smoothness of the streaming output is a primary KPI.
  • High-speed networking: Possession of the infrastructure to handle sub-millisecond cache transfers.

For smaller models or workloads with short context windows and low concurrency, the overhead of transferring KV caches might outweigh the benefits. In those cases, sticking to a well-tuned aggregated serving model with smart routing is often the more pragmatic choice.

Case study: optimizing GLM 5.2 on enterprise hardware

To anchor these concepts in reality, consider the ongoing research into serving models like GLM 5.2. While many high-end benchmarks focus on the latest B200 GPUs, most enterprises operate on H100 or H200 clusters. Optimizing a 45:1 I/O ratio workload on this hardware requires a modular architecture that combines multiple parallelism strategies.

In high-performance testing, researchers have designed pre-fill pools using multiple workers optimized for throughput via distributed parallelism, while using a single dedicated worker for the decode pool to maintain low latency. By using NCCL for efficient KV transfer, these setups have achieved 4x faster TTFT and 60% higher request capacity compared to standard configurations.

This modularity is the key to scalability. By adding pre-fill workers without needing to reconfigure the decode pool, organizations can handle increasingly complex agentic prompts without sacrificing the interactive quality of the responses. This level of granular control over the worker pools allows the infrastructure to adapt to the specific needs of the agent, whether it is a code generator processing a massive repository or a research agent scanning thousands of pages of documentation.

Strategic implications for the enterprise AI stack

For the modern enterprise, the transition to agentic AI infrastructure is a move toward what we call sovereign operability. Relying on generic SaaS wrappers or ungoverned shadow AI leads to unpredictable costs and fragile performance. As organizations move beyond simple experiments and into the deployment of autonomous systems, the underlying infrastructure must be treated as a core utility - one that is persistent, scheduled, and auditable. This is the same argument for owning your cloud agent platform and infrastructure sovereignty rather than renting it from a black-box vendor.

This research highlights why production-grade hosting for the agent layer cannot be an afterthought. The complexity of managing KV caches, phase interference, and network topologies creates a massive barrier for companies trying to build these systems from scratch. This is why the industry is shifting toward managed instances and sovereign platforms that provide this infrastructure out of the box.

At Ability.ai, we see these technical challenges as the primary reason organizations struggle to move from a pilot to a full-scale transformation. Our Trinity platform is designed precisely to handle this level of operational complexity. By providing a sovereign, managed environment that prioritizes persistent shared state and governed data flow, we allow builders and CTOs to focus on business outcomes rather than the physics of GPU interference. If you would rather not build and run this serving stack yourself, Ability's managed agent operations set up Trinity, build your agents, and keep them running in production as your service.

The path forward for operations leaders is clear - stop chasing raw throughput numbers from sanitized benchmarks and start architecting for the chaotic reality of the agentic era. By implementing smart routing and considering the disaggregation of your compute stack, you can transform fragmented AI experiments into a reliable, high-performance engine that your organization truly owns and controls. The goal is no longer just to generate text; it is to create an infrastructure that is as reliable as the employees it augments.

Key takeaway
KV cache routing (also called prefix-aware routing) is a scheduling technique that sends each agent request to the GPU pod that already holds its Key-Value cache, instead of rebuilding that context from scratch. An intelligent router scores every pod on cache locality and load, then pins a conversation to the pod that already stores its system prompt and tool definitions.

Questions

Frequently asked questions about KV cache routing

What is KV cache routing?
KV cache routing (also called prefix-aware routing) is a scheduling technique that sends each agent request to the GPU pod that already holds its Key-Value cache, instead of rebuilding that context from scratch. An intelligent router scores every pod on cache locality and load, then pins a conversation to the pod that already stores its system prompt and tool definitions.
Why do agentic workloads break traditional LLM serving?
Traditional serving was tuned for short, predictable chats. Agentic workloads run extreme multi-turn sessions - sometimes 3,000+ turns - with input-to-output ratios above 100:1, which causes phase interference and cache misses on standard round-robin deployments. Without cache-aware routing, the system rebuilds the same large context repeatedly, wasting compute and inflating token cost.
How much does KV cache routing improve performance?
In multi-turn interactions, reusing the KV cache can cut time-to-first-token from around 3 seconds to under 1 second, and cache hit rates in optimized environments often exceed 90%. Because cached tokens can cost up to 10x less than fresh ones, routing for cache locality lowers both latency and spend at the same time.
When should I use pre-fill/decode disaggregation?
Consider PD disaggregation when you have long contexts, large models needing rich parallelism, strict inter-token latency requirements, and high-speed networking (RDMA or RoCE) to move caches between pods. For smaller models with short contexts and low concurrency, the transfer overhead usually outweighs the benefit, so a well-tuned aggregated server with smart routing is the more pragmatic choice.
Do I need to build this infrastructure myself?
Not necessarily. Managing KV caches, phase interference, and network topologies is a significant engineering burden, which is why many organizations run their agents on a sovereign managed instance that provides this infrastructure out of the box - keeping data inside their own perimeter while offloading the operational physics of GPU serving.