KVFlow: Efficient Prefix Caching for Accelerating LLM-Based Multi-Agent Workflows

Zaifeng Pan, Ajjkumar Patel, Yipeng Shen, Zhengding Hu, Yue Guan, Wan-Lu Li, Lianhui Qin, Yida Wang, Yufei Ding

Abstract

Multi-agent Large Language Model (LLM) workflows often involve iterative interactions between specialized agents, each utilizing large, fixed system prompts. While prefix caching can mitigate redundant computations, standard cache eviction policies like Least Recently Used (LRU) are suboptimal for structured agentic loops, frequently evicting data that will be needed in the immediate future. We present KVFlow, a workflow-aware KV cache management framework that models agent dependencies to predict future usage. By implementing workflow-aware eviction, proactive prefetching, and status-aware scheduling, KVFlow achieves up to a 2.19× speedup over state-of-the-art systems.

Introduction: The Blind Spot of LRU in Agentic Workflows

In modern "agentic workflows," specialized LLM agents—such as Planners, Executors, and Reviewers—collaborate to solve complex tasks. Each agent typically operates under a substantial "system prompt" defining its role and constraints. To optimize performance, systems employ prefix caching, storing the Key-Value (KV) tensors of these prompts to avoid recomputation.

However, GPU memory constraints necessitate an eviction policy. Current systems predominantly use a Least Recently Used (LRU) strategy. In iterative workflows, this creates a significant bottleneck: an agent used at the start of a loop (e.g., a "Planner") may be evicted while a subsequent agent (e.g., an "Executor") is running, simply because it hasn't been accessed recently. This leads to avoidable cache misses and increased prefill latency when the loop restarts.

LRU-based eviction leads to cache misses in iterative agentic workflows as the least recently used agent is often the next one needed.

The KVFlow Framework

KVFlow addresses these inefficiencies through three primary technical innovations:

1. Agent Step Graph and Workflow-Aware Eviction

Instead of treating requests as independent events, KVFlow abstracts the multi-agent workflow into an Agent Step Graph. This graph allows the system to calculate a "steps-to-execution" metric for every agent, estimating how soon an agent will be required based on the workflow's logical structure, including loops and branches.

KVFlow replaces LRU with a policy that evicts KV caches with the largest "steps-to-execution" values. This logic is applied to a radix tree structure. To protect shared knowledge, KVFlow utilizes a "conservative merge" strategy: a parent node in the tree inherits the minimum priority (lowest steps-to-execution) of its children, ensuring shared prefixes are not prematurely deleted if any descendant agent requires them soon.

KVFlow's eviction priority propagation ensures shared prefixes are retained based on the minimum steps-to-execution of descendant agents.

2. Overlapped KV Prefetching

By leveraging the predictive power of the Agent Step Graph, KVFlow proactively "prefetches" required KV tensors from CPU memory to the GPU in the background. This allows the system to hide the latency associated with PCIe data transfers.

3. Status-Aware Scheduling

To ensure the GPU remains productive during data transfers, the Status-Aware Scheduler dynamically reorders tasks. If a high-priority request is still waiting for its KV cache to be prefetched, the scheduler will temporarily bypass it to run a different request that is already "cache-ready," maximizing hardware utilization.

Evaluation and Results

The researchers evaluated KVFlow using both synthetic 10-agent sequential pipelines and realistic simulations based on the PEER framework with a Financial QA dataset. Tests were conducted on NVIDIA A10G (Llama-3.1-8B) and H100 (Qwen2.5-32B) GPUs.

  • Performance Gains: For single workflows with large prompts (8192 tokens), KVFlow achieved a 1.83× speedup over SGLang. In high-concurrency scenarios where memory contention is high, the speedup reached 2.19×.
  • Latency Mitigation: While standard LRU-based systems experienced significant prefill latency spikes during cache misses, KVFlow successfully "hid" these costs, maintaining low latency by ensuring data availability through prefetching.

Conclusion and Future Work

KVFlow demonstrates that workflow awareness is critical for optimizing LLM serving in multi-agent environments. By flipping the logic of LRU to prioritize "soon-to-be-used" data, KVFlow significantly reduces redundant computation and data transfer stalls.

Future research may focus on handling highly dynamic workflows where the "Agent Step Graph" is less predictable, or integrating KVFlow with speculative decoding and more granular cost models to further refine scheduling and eviction priorities.

Summary updated

BibTeX
@inproceedings{pan2025kvflow,
  author = {Zaifeng Pan and AJJKUMAR PATEL and Yipeng Shen and Zhengding Hu and Yue Guan and Wan-Lu Li and Lianhui Qin and Yida Wang and Yufei Ding},
  title = {{KVFlow: Efficient Prefix Caching for Accelerating LLM-Based Multi-Agent Workflows}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2025},
  url = {https://openreview.net/forum?id=5Iw1nDtYmT},
}
Figure