MemAgent: Reshaping Long-Context LLM with Multi-Conv RL-based Memory Agent

Hongli Yu, Tinghong Chen, Jiangtao Feng, Jiangjie Chen, Weinan Dai, Qiying Yu, Ya-Qin Zhang, Wei-Ying Ma, Jingjing Liu, Mingxuan Wang, Hao Zhou · DOI

Introduction

As Large Language Models (LLMs) evolve, the demand for processing massive context windows has led to a "long-context" arms race. However, current architectures face a fundamental trilemma: they struggle to process virtually infinite text, maintain performance without "cliffs" during extrapolation, and keep computational costs linear. Standard Transformers rely on self-attention, which scales quadratically ($O(N^2)$), making ultra-long context processing prohibitively expensive and prone to degradation once input exceeds training lengths.

MemAgent proposes an "anthropocentric" solution. Rather than attempting to brute-force the entire context window, it treats the LLM as a proactive controller that manages a fixed-length memory, distilling the essence of a document much like a human taking notes while reading.

Methodology: The Memory Agent Workflow

The core innovation is the MemAgent workflow, which transforms the LLM into a memory-managing agent.

Comparison of standard long-context LLM processing vs. the MemAgent workflow.

Sequential Memory Updates

The model processes text in discrete segments or "chunks." For each chunk, the model receives the current text and its previous "memory"—a sequence of standard tokens. It then generates an "Updated Memory," effectively overwriting the previous state. This cycle continues until the entire document is processed, at which point the final memory is used to generate the answer. By forcing the model to overwrite a fixed-length memory (e.g., 1024 tokens), the system maintains $O(N)$ linear complexity.

Multi-Conv RL Training

Training an agent to manage memory is challenging because memory updates are "latent"---there is no direct supervision for what the model should "note down." To address this, the authors developed Multi-Conv DAPO (Direct Alignment with Policy Optimization). This approach treats each segment-processing step as an independent conversation but optimizes them globally based on the final answer's correctness. Using a variant of GRPO (Group Relative Policy Optimization), the model is rewarded when its memory management leads to a correct final answer, teaching it to discard distractors and retain only answer-critical facts.

Experimental Evaluation

MemAgent was evaluated using rigorous benchmarks including RULER (NIAH variants, variable tracking), HotpotQA (multi-hop training), and SQuAD (out-of-distribution testing). Models were trained on documents of approximately 32K tokens and tested on context lengths extending up to 3.5 million tokens.

Key Results and Performance

The most striking result of MemAgent is its ability to bypass the "performance cliff" typical of long-context models. While most models see accuracy plummet to zero once they exceed their training length by a small margin, MemAgent demonstrates a remarkably flat performance curve.

Performance of MemAgent vs. baselines across context lengths up to 3.5M tokens.
  • Extreme Extrapolation: A MemAgent model with an 8K context window maintained over 95% accuracy on the RULER test at 512K tokens.
  • Lossless Scaling: On a 3.5-million-token QA task, MemAgent-14B achieved an accuracy of 78.12%, representing a performance loss of less than 5% compared to its performance at 7K tokens.
  • Baseline Comparison: Specialized models like QwenLong-L1-32B saw accuracy drop from ~72% to ~11% when scaled to 896K tokens.
  • Efficiency: Computational costs grow linearly, making ultra-long context processing economically viable compared to the quadratic explosion of standard baselines.

Discussion and Limitations

MemAgent's memory exists in token space, making the model's "notes" human-readable and inspectable. However, the sequential nature of memory updates introduces a bottleneck, as chunks cannot be fully parallelized in the same manner as standard Transformers. Additionally, while a 1024-token memory is robust for many tasks, information-dense documents may eventually require dynamic memory sizing. Future work will explore these scaling dynamics and the complexities of multi-turn RL training.

Summary updated

BibTeX
@inproceedings{yu2026memagent,
  author = {Hongli Yu and Tinghong Chen and Jiangtao Feng and Jiangjie Chen and Weinan Dai and Qiying Yu and Ya-Qin Zhang and Wei-Ying Ma and Jingjing Liu and Mingxuan Wang and Hao Zhou},
  title = {{MemAgent: Reshaping Long-Context LLM with Multi-Conv RL-based Memory Agent}},
  booktitle = {International Conference on Learning Representations},
  year = {2026},
  url = {https://openreview.net/forum?id=k5nIOvYGCL},
}
Figure