Manuscript Offprint

arXiv:2610.41056

Accept Changes, Reject Attacks: Robust Memory Management for LLM Agents

Runze Zhao, Dongruo Zhou, Sumit Kumar Jha, Nathaniel D. Bastian, Ankit Shah

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Since large language model (LLM) agents rely on long-term memory, what they store now shapes what they do later. A memory manager decides how each input changes this memory and which records the agent acts on. It can fail in two ways: keeping a fact that has since changed (outdated memory), or storing a planted passage or injected instruction (memory poisoning). Most prior work studies them separately, yet they call for opposite write decisions, so no fixed write rule handles both. We therefore formalize memory robustness as handling both without doing worse on other inputs. Since accuracy checks only the answer, we measure robustness with evidence-conditioned accuracy (ECA), which also checks that the records the manager selects include all the evidence the answer needs, updated and free of attacks. However, existing memory systems and defenses are not more robust than an untuned manager on our test sets. We improve robustness with a simple one-shot recipe that fine-tunes the manager on episodes synthesized around a single conversation with inserted changes and attacks. On three backbones, it improves every category score on our test sets and more than doubles the untuned manager's overall ECA, though robustness remains incomplete.

1 Introduction

Large language model (LLM) agents keep a long-term memory outside the context window, so that what they learn in one session is available in later ones. A personal assistant, for example, remembers facts and preferences about its user (Packer et al., 2023; Zhong et al., 2024). In such agents, a memory manager decides for each new input whether and how the memory should change, and which stored records the agent acts on (Chhikara et al., 2025; Xu et al., 2025; Yan et al., 2026). Every write

and every selection thus affects what the agent does later. Yet the inputs come from many sources, not all of them under the agent's control.

As Figure 1 shows, a write can go wrong in two ways. In outdated memory, a fact has changed but the memory keeps the old value (Chao et al., 2026); in Figure 1a, the user has moved to a new city. In memory poisoning, an attacker uses one of these inputs to place content in memory that should never be there (Greshake et al., 2023; Dong et al., 2025), such as the injected instruction in Figure 1b. Every memory manager may face both problems, and they call for opposite write decisions. Following a change requires writing the new input, while keeping out an attack requires not writing it, so no fixed write rule handles both. We therefore distinguish three categories of input. An input is in the outdated category if its speaker reports a change to a stored fact about themselves, which makes the stored record outdated. Poisoning inputs carry an attack, and all other inputs are standard.

Most prior work evaluates each problem on its own, and a trivial manager can pass each such evaluation. Memory benchmarks contain no attacks, and managers trained on them never see one (Wu et al., 2025; Chao et al., 2026; Yan et al., 2026), so a manager that writes every input scores high while storing every attack. Evaluations of poisoning and injection defenses check standard inputs, not whether changes to stored facts are still written (Wei et al., 2026; Chen et al., 2025a; Wallace et al., 2024; Li et al., 2025), so a manager that never changes a stored fact scores high while missing every change. No widely used benchmark covers both problems. We therefore formalize memory robustness over all three categories, so that a gain in one category cannot hide a loss in another. Measuring it also needs a new metric, since accuracy (ACC) checks only the answer, not the memory it is based on.

Unlike a fixed write rule, a manager that tells

*Corresponding author.

Figure

Figure 1: Two cases a memory manager must handle: (a) outdated memory and (b) memory poisoning. Each panel shows an incorrect (red) and a correct (green) write, with the memory each write leaves (yellow).

changes from attacks can handle both, writing the first and keeping the second out of the records it selects. A simple one-shot synthesis around a single conversation of an existing dataset is enough to teach this distinction. Our contributions are:

  • A complete definition of memory robustness. Unlike prior one-sided formulations, ours covers all three categories equally; a manager is more robust than another if it is no worse in any category and better in at least one. We measure each category with a new metric, evidence-conditioned accuracy (ECA), which counts an answer only if it is correct and the records the manager selects include all the evidence it needs, updated and free of attacks.

  • A simple one-shot data synthesis recipe. To improve robustness under this definition, we synthesize training data around a single conversation of an existing dataset. We insert the fact changes and memory attacks studied in prior benchmarks into this conversation and train the manager on the resulting episodes with plain supervised fine-tuning (SFT). One conversation is enough because it stays fixed while the inserted turns differ in whether and how they should change memory, so the manager learns this decision rather than the conversation. Turns whose correct write can be predicted from surface cues such as word overlap or position are discarded.

  • Experiments. Across three backbones, SFT raises ACC and ECA in every category of our test sets over the untuned manager (the same backbone before fine-tuning) and lowers the attack success rate (ASR). Since ECA also checks the selected records, these gains show that training improves which records the manager stores and selects, not only the answers. SFT is the

only method that raises ECA in all three categories, while each memory system and defense we compare falls below the untuned manager in at least one. On Qwen3-4B, SFT also raises ECA on all eight benchmarks, five of them unseen in training.

References (15)