Tokencake: A KV-Cache-centric Serving Framework for LLM-based Multi-Agent Applications

Zhuohang Bian, Feiyang Wu, Teng Ma, Youwei ZhuoarXiv 2025 · DOI

Abstract

As Large Language Model (LLM) applications transition from simple chatbots to complex multi-agent systems, they encounter a significant "memory wall." Existing serving frameworks struggle with the unique execution patterns of these systems, specifically long periods of idle memory during external tool calls and inefficient resource contention between agents. We introduce Tokencake, a serving framework that treats the Key-Value (KV) Cache as a first-class citizen. By implementing proactive memory offloading and priority-aware scheduling, Tokencake achieves a 47% reduction in end-to-end latency compared to state-of-the-art systems like vLLM.

Introduction: The Memory Wall in Multi-Agent Systems

Modern multi-agent workflows, such as autonomous coding or deep research, differ fundamentally from standard LLM requests. They are characterized by two primary bottlenecks that traditional First-Come-First-Served (FCFS) schedulers cannot address:

  1. Time Underutilization: Agents frequently invoke external tools (APIs, web searches, or file operations). During these calls, the agent's KV Cache—its "short-term memory"—remains in expensive GPU memory without being used, blocking other active requests.
  2. Space Contention: In complex workflows, low-priority background tasks can arrive first and occupy memory, forcing the system to evict the KV Cache of "critical path" agents. This leads to "critical inversion," where the most important tasks suffer massive delays due to the need to recompute their entire context from scratch.
Figure 6: Illustration of KV-Cache underutilization during and after external tool calls, highlighting the trade-off between maintaining and evicting cache.

The Tokencake Architecture

Tokencake addresses these challenges through a KV-Cache-centric architecture that co-optimizes scheduling and memory management across the GPU-CPU hierarchy.

Proactive Time Scheduling

Instead of reactive eviction, Tokencake's Time Scheduler is "function-call aware." When an agent initiates a tool call, the system proactively offloads its KV Cache to CPU memory. Using a predictive model to estimate tool latency, the scheduler "pre-uploads" the cache back to the GPU just before the call completes, effectively hiding data transfer latency. This is justified by the massive performance gap: transferring 4096 blocks takes approximately 60ms, whereas recomputing them can take nearly 9,000ms.

Priority-Aware Space Scheduling

To prevent critical inversion, the Space Scheduler implements dynamic memory partitioning. It reserves a portion of GPU memory for critical agents identified via a developer-defined Directed Acyclic Graph (DAG). A Hybrid Priority Metric combines static DAG position with dynamic runtime data to ensure that high-impact agents are protected from eviction.

Low-Level Memory Optimizations

To minimize the overhead of frequent offloading, Tokencake employs CPU Block Buffering to bypass slow system calls and Gradual GPU Block Reservation to prevent allocation spikes that could stall the inference engine. These optimizations reduce offloading overhead from seconds to single-digit milliseconds.

Evaluation and Results

Figure 1: Representative multi-agent workflows used for evaluation: (a) Multi-agent Coding and (b) Deep Research.

The authors evaluated Tokencake using two representative benchmarks: Code-Writer (specialized agents with frequent file system calls) and Deep Research (complex planning and summarization dependencies). User requests were synthesized from ShareGPT and AgentCode datasets, with tool latencies modeled on the Model Context Protocol (MCP).

Key performance metrics include:

  • Latency Reduction: Tokencake reduced average end-to-end latency by over 47.06% compared to vLLM under high load.
  • Memory Efficiency: Effective GPU memory utilization improved by up to 16.9% by keeping the GPU focused on active, ready-to-run agents.
  • System Reliability: The framework significantly reduced the count of "abnormal" agents (those exceeding 1.5x their average execution time), providing a more stable execution flow for complex workflows.

Conclusion and Future Work

Tokencake demonstrates that in the agentic era, scheduling must evolve from managing computation to managing memory across the GPU-CPU hierarchy. While currently focused on single-GPU setups and static DAGs, future work will explore tiered memory management across multiple GPUs (using NVLink) and more sophisticated latency prediction models that incorporate function arguments to further refine proactive offloading.

Summary updated

BibTeX
@misc{bian2025tokencake,
  author = {Zhuohang Bian and Feiyang Wu and Teng Ma and Youwei Zhuo},
  title = {{Tokencake: A KV-Cache-centric Serving Framework for LLM-based Multi-Agent Applications}},
  year = {2025},
  eprint = {2510.18586},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.18586},
}
Figure