Evaluating KV-Cache Eviction Policies for LLM Agents: The Effect on the Shared System Prompt
Ampavatina, Hriday, Eirinaki, Magdalini
–arXiv.org Artificial Intelligence
Large Language Model (LLM) agents run long sessions that all begin with the same system prompt, which holds the agent's instructions and the documentation of its tools. Serving engines store this shared prefix once for all sessions, so removing it from the key-value (KV) cache of one session frees no memory, but the session loses the documentation that the agent needs to call its tools. Published KV-cache eviction policies treat every cached token the same way against the memory budget, so they remove the shared prefix like any other text. In this paper, we measure seven published eviction policies on recorded sessions of SWE-agent, a coding agent, and we count the memory of each session the way a serving engine does, with the shared prefix counted once for all sessions. We test four models of the Qwen2.5 and Llama-3.1 families, with 1.5 to 14 billion parameters. When a session keeps an eighth of its cache, four of the policies, which choose tokens by attention or by position, keep at most 14% of the shared prefix, and the model can rarely recall how to call its tools. Under prefix caching, keeping the whole prefix costs no extra memory per session, and it lets the model recall its tool documentation in nearly every case. Keeping the prefix also improves how often the agent's next commands follow the command format documented in the system prompt by 10 to 22 percentage points on three models. For five of the six policies that we test on recall, it never significantly lowers the recall of facts from the session's own history (the part of its input after the shared prefix). Our results show that a serving engine with prefix caching can keep the shared prefix out of eviction at no memory cost, and that the agent then recalls its tool documentation and writes valid commands more often.
arXiv.org Artificial Intelligence
Dec-2-2026