cs.AIOct 19, 2026

REM: What to Store, When to Recall, What to Forget in Experience Memory for Coding Agents

Authors: Xinyi Lisa Chen, Pedro Herrero-Vidal, Xiaohan Chen, Xiaojing Yu, Cris Liu, Bingqing Song, Bin Xu, Suleiman A. Khan, 

Organizations: Yale University · Amazon

Abstract

Large language model (LLM) agents now autonomously complete long-horizon tasks, such as repository-level coding, through hundreds of think-act steps, yet the experience each run produces is rarely reused on the next. Prior memory systems concentrate on retrieval, finding the most relevant past trajectory. Retrieval cannot observe the running agent, so it cannot decide whether the agent needs an experience, at which point, or for how long. We introduce REM (Reusable Experience Memory), a framework that manages the memory lifecycle from inside the agent's think-act loop through three explicit decisions. What to store: each completed trajectory is consolidated into a phase-structured document, two orders of magnitude smaller than the trajectory. When to recall: the document is injected at the start of the task; the costlier implementation record is withheld until an in-loop gate detects the agent struggling. What to forget: the record is evicted after a single exposure. On repository-level bug fixing (SWE-ContextBench Lite), REM retrieves the related trajectory more accurately than every state-of-the-art memory system (68.7% vs. 55.6% match@1) and improves, in every replicate, end-task resolution (27.6% vs. 24.9%) at 17% lower cost. Injecting the same experience as a summary or raw trajectory, even when oracle-retrieved, does not. Ablating any of the three decisions reduces resolution. Altogether, these results demonstrate that the bottleneck in experience reuse is not retrieval fidelity but how experience is stored and governed across its lifecycle, opening a control-theoretic perspective on agent memory.

Figures & tables

Appendix figures & tables11 assets

Supplementary material from the paper’s appendix.

Appendix

Explore similar work

CardsList
  1. DELTAMEM: Incremental Experience Memory for LLM Agents via Residual Trees

    Jun 2, 2026Haoran Tan, Zeyu Zhang, Zhicheng Cao +2Continual Learning for LLM AgentsLLM Agent Memory

  2. Memex(RL): Scaling Long-Horizon LLM Agents via Indexed Experience Memory

    Mar 4, 2026Zhenting Wang, Huancheng Chen, Jiayun Wang +1LLM Agent MemoryMemory Management for LLM Agents

  3. CoMem: Learning to Anticipate Failures from Retrieved Experience

    Oct 19, 2026Yun Shen, Ming Shen, Tianjun YaoMemory-Augmented Language Model AgentsSelf-Reflection in Language Model Agents