TL;DR
LLM agents are notoriously "chatty," resending their entire conversation history every time they call a tool. EfficientAgent reveals that offloading this conversation history (KV cache) to CPU memory often fails because concurrent agents "thrash" the cache, evicting data before it can be reused. By modeling the "reuse working set" and using a smart admission policy, the authors cut recomputation by 93% and speed up agent tasks by 39%.
What Problem Does This Paper Address?
LLM agents (like those solving coding tasks) work in a loop: they read a task, call a tool (like a compiler), read the result, and call the LLM again. Each new call includes the entire previous conversation. To save time, serving systems use prefix caching, which stores the mathematical state (Key-Value or KV cache) of previous tokens so they don't have to be recomputed.
When GPU memory runs out, systems "offload" this KV cache to the host (CPU) memory. However, this often yields inconsistent results. Sometimes offloading makes things faster; other times, it actually slows the system down—even when the hardware bandwidth suggests it should be a win.
The authors identify the culprit: cache thrashing. In a multi-agent environment, while Agent A is waiting for a tool to finish, Agents B, C, and D are using the server. If the host memory isn't large enough to hold the "working set" of all active agents, Agent A’s data gets evicted to make room for the others. When Agent A returns, its data is gone, and the system has to recompute everything anyway, having wasted time and bandwidth on a useless transfer.
Methods
The researchers introduce EfficientAgent, which manages the host memory tier based on two main components:
- Stack-Distance Modeling: Borrowing from classic operating system theory, they use a model to estimate the "reuse working set"—the total memory needed to ensure an agent finds its data when it returns. This allows them to predict exactly how much host memory is needed before deploying the agents.
- Capacity-Conditioned Admission: At runtime, the system monitors memory pressure. If the estimated working set exceeds the available host memory, the system stops trying to save large "refills" of data that are likely to be evicted soon. Instead, it only saves small incremental updates to prefixes that are already safely cached.
- Hardware Profiling: They define an "Offload Benefit Ratio" (OBR) to determine if a specific GPU/CPU combo should offload. For example, high-compute GPUs like the H800 can recompute tokens so fast that moving them over a PCIe link is actually slower than just doing the math again.
Datasets
The study evaluates its approach using:
- SWE-bench Verified: A benchmark consisting of real-world GitHub issues. This provides realistic, long-context trajectories for coding agents.
- OpenHands: An open-source platform for building autonomous AI agents, used here to run the
CodeActAgentwith theQwen3-Coder-30Bmodel.
Key Insights and Ideas
- Residency is King: A cache hit is only valuable if the data stays resident until it's needed. Transferring data to a cache that is too small is "wasted work" that adds latency without saving computation.
- The Compute-to-Bandwidth Gap: Offloading is a hardware-dependent gamble. On an RTX 3090 or H20, loading a token from CPU memory is ~6x cheaper than recomputing it. On an H800, the GPU is so powerful that recomputing is often faster than the PCIe transfer.
- Load Control Prevents Thrashing: Much like an OS manages virtual memory to prevent a computer from freezing, LLM servers need "load control" for the KV cache. By being selective about what they store during high pressure, they protect the hits they can keep.
Key Results
The authors tested their system on eight H20 GPUs replaying SWE-bench tasks.
- Massive Efficiency Gains: By sizing the host tier to the predicted working set (moving from 5 GiB to 20 GiB per rank), they reduced recomputed prompt tokens by 93.1% and cut the total "makespan" (time to finish all tasks) by 38.7%.
- Policy Success: Their conditioned admission policy successfully navigated the "transition region." In small-memory scenarios, it cut recomputation by 35% compared to naive offloading. In large-memory scenarios, it automatically stepped out of the way to avoid unnecessary filtering.
- Hardware Realities: They confirmed that offloading is a net win for the RTX 3090 and H20 but a net loss for the H800, where the ratio of compute power to PCIe bandwidth is too high.
Limitations and Future Work
- Context Editing: The paper notes that "history condensers" (which summarize or truncate old parts of a chat) can be counter-productive. Because prefix caching relies on exact matches, changing even one early token "rekeys" the entire subsequent conversation, rendering the existing cache useless.
- Static vs. Dynamic: While the stack-distance model is powerful, the authors suggest that future work could better handle highly dynamic agent behaviors where tool-call times vary wildly.
- Disaggregated Serving: The researchers point toward applying these working-set principles to "disaggregated" systems, where KV caches are shared across entire clusters of servers rather than just between a GPU and its host CPU.
Summary updated