Aborted but Not Forgotten: KV-Cache Retention Breaks Rollback Consistency in Language Agents
Organizations: The Hong Kong University of Science and Technology
Abstract
Stateful language agents assume a rejected branch can be taken back by clearing it from the application transcript. We show this breaks when the serving session retains key/value (KV) state across the logical abort: the model can continue attending to content the application believes it discarded. We formalize the missing guarantee as rollback consistency: a complete abort must restore the state the model attends, not just the transcript. The key failure is cross-layer: a correct logical rollback need not compose with retained inference state, and the gap can remain invisible to the application. To isolate cache effects from text effects, we introduce a same-token/different-cache audit that holds decision-step tokens identical while varying only whether the cached prefix is stale or rebuilt from committed state. Across seven open-weight families (3.8B-36B), retained KV alone flips a typed protected effect in 25 of 63 audited cells, while attacker tokens are absent from the served request in all 63; rebuilding the cache closes every cell. The channel reproduces in an end-to-end session application, on the default Hugging Face Transformers cache-reuse path, and under LangGraph time-travel, where verified logical rollback can still leave attended KV stale. Susceptibility varies across models, but the underlying attended-state integrity violation is structural. We rule out position and length confounds, generalize across protected effects, policy structures, and a cache-isolated Mixture-of-Experts model, and show that transaction-local cache restoration closes the channel without requiring a global cache flush. All headline results are deterministic and reproducible from released artifacts.
Figures & tables
| cache census (of 9) | isolation (of 9) | session app | |||||
|---|---|---|---|---|---|---|---|
| Model | stale | text | fresh | cold | carrier abs. | tok. id. | buggy / fresh |
| Phi-3.5-mini (3.8B) | 9 | 9 | 0 | 0 | 9 | 9 | 9 / 0 |
| GLM-4-9B | 9 | 9 | 0 | 0 | 9 | 9 | 9 / 0 |
| Granite-3.3-8B | 6 | 6 | 0 | 0 | 9 | 9 | 6 / 0 |
| Qwen2.5-14B | 1 | 1 | 0 | 0 | 9 | 9 | 1 / 0 |
| DeepSeek-R1-Distill-Llama-8B | 0 | 0 | 0 | 0 | 9 | 9 | 0 / 0 |
| Defense | Closes channel? | Attack exfiltration | Why / cost |
| Framework-native abort (buggy retain) | no | drops transcript, keeps KV handle | |
| Prompt-level “distrust rejected” guard | no | (GLM-4 ) | residue in KV not labelled rejected |
| Full restart / global cache flush | yes | disrupts all co-tenants (§ 4 ) | |
| Restore: rebuild (transaction-local) | yes | re-prefill committed prefix; tenant | |
| Restore: truncate-to-commit | yes | crop stale KV to committed length; tenant | |
| Restore: checkpoint-restore | yes | restore pre-abort KV snapshot; tenant |
Appendix figures & tables7 assets
Supplementary material from the paper’s appendix.
Appendix
| retrieved_doc | tool_return | user_turn | |||||||
|---|---|---|---|---|---|---|---|---|---|
| Model | neu | sug | imp | neu | sug | imp | neu | sug | imp |
| Phi-3.5-mini (3.8B) | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
| GLM-4-9B | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
| Granite-3.3-8B | 0 | 0 | 1 | 1 | 1 | 1 | 0 | 1 | 1 |
| Qwen2.5-14B | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 |
| DeepSeek-R1-Llama-8B | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
| Model | identifying probe | session app |
|---|---|---|
| Phi-3.5-mini | bc2609b0eb671b10 | fcd24a93ddde1e2e |
| GLM-4-9B | cce6736e92f7429d | f1f799830e1e3f40 |
| Granite-3.3-8B | 8cb805fa2ff095a3 | 410f635b0f27aff9 |
| Qwen2.5-14B | d4f77e95c91f7ccd | 18e8a8cd565d06b9 |
| DeepSeek-R1-Llama-8B | 9894659ed54bfaa1 | eda37906c100b65c |
| Phi-4 (14B) | 928823f7678eaf0e | d07cd9e5257db532 |
| Model | attacker-stale | neutral-stale | cache-len eq. | fresh | truncate | checkpoint |
|---|---|---|---|---|---|---|
| Phi-3.5-mini | yes | |||||
| GLM-4-9B | yes | |||||
| Granite-3.3-8B | yes | |||||
| Qwen2.5-14B | yes | |||||
| Total | flips | |||||
| Qwen3-30B-A3B (MoE) | yes |
| Model | message | payment | file-del. | cred. | |
|---|---|---|---|---|---|
| Phi-3.5-mini | |||||
| GLM-4-9B | |||||
| Granite-3.3-8B | |||||
| Qwen2.5-14B | |||||
| DeepSeek-R1-Llama-8B | |||||
| Susceptible total |
| Stack / mechanism (default configuration) | KV reuse across a logical abort | exposure |
| vLLM V1 automatic prefix caching (on by default) ( Kwon et al., 2023 ; vLLM Project, 2026 ) | content-addressed block hashing, re-derived from request | self-healing |
| SGLang RadixAttention ( Zheng et al., 2024 ) | radix tree keyed by token prefixes of the request | self-healing |
| llama.cpp llama-server slots ( cache_prompt default) ( ggml-org, 2026 ) | per-slot KV retained but reused by longest-common-prefix match against the incoming request | self-healing on divergence † |
| Stateless re-prompt each turn (message-level agent frameworks) | recomputed from the full transcript | self-healing |
| Transformers multi-turn DynamicCache continued generation ( Hugging Face, 2026 ) | retained handle advanced by the new-turn delta | exposed (verified, § 3 , 3.2 ) |
| Session-keyed serving handle / agent-memory KV cache | retained handle advanced per turn | exposed (verified, § 3.2 ) |
Adversarial Robustness of Language Models
Adversarial robustness of language models studies how to keep their outputs and decisions reliable under manipulative prompts, input changes, and malicious fine-tuning.
See all 192 papers