MemSearcher: Training LLMs to Reason, Search and Manage Memory via End-to-End Reinforcement Learning

Qianhao Yuan, Jie Lou, Zichao Li, Jiawei Chen, Yaojie Lu, Hongyu Lin, Le Sun, Debing Zhang, Xianpei Han · Submission to ICLR 2026 · Withdrawn

TL;DR

Standard ReAct-style search agents append full conversation histories to their context, causing token usage and compute costs to explode over multi-turn interactions. MemSearcher solves this by having the model iteratively maintain a compact, bounded natural language memory containing only task-essential facts. Trained end-to-end with multi-context GRPO, MemSearcher keeps context lengths nearly constant while significantly boosting retrieval accuracy—enabling a 3B model to surpass 7B ReAct baselines.

What Problem Does This Paper Address?

When large language models (LLMs) act as search agents, they typically follow the ReAct paradigm: alternating between reasoning, taking search actions, and observing retrieved documents. Under ReAct, the full history—every past thought, query, and multi-paragraph search response—is concatenated into the model's context window.

This setup introduces two major bottlenecks:

  1. Computational & Memory Blowup: Context length scales linearly with interaction turns ($O(n)$ tokens), which translates to quadratic computational overhead ($O(n^2)$) and surging peak GPU memory.
  2. Context Pollution: Long, noisy search passages degrade LLM reasoning due to distraction, noise, and well-known "lost-in-the-middle" phenomena.

Dropping history entirely and keeping only the current turn avoids overhead, but discards vital intermediate discoveries. MemSearcher resolves this tension by providing a mechanism to preserve information integrity within a strictly bounded context.

Methods

MemSearcher replaces full-history concatenation with an iterative read-and-update memory workflow:

Turn i Context: [ User Question (q) ] + [ Compact Memory (m_{i-1}) ]
      │
      ├─► LLM generates: <think> ... </think> and <tool_call> query </tool_call>
      ├─► Search Engine returns: <tool_response> observation (o_i) </tool_response>
      └─► LLM updates memory: <memory> m_i </memory>  (Max 1,024 tokens)
  1. MemSearcher Workflow: At turn $i$, the model receives only the original question $q$ and the previous turn’s compact memory $m_{i-1}$. After receiving the search observation $o_i$, the LLM acts as its own memory manager: it extracts relevant findings from $o_i$, merges them with $m_{i-1}$, and writes an updated summary $m_i$ (constrained to 1,024 tokens).
  2. Multi-Context GRPO: Standard Group Relative Policy Optimization (GRPO) assumes rollouts occur under a single static context. In MemSearcher, a single agent trajectory consists of multiple sequential turns, each conditioned on a different context $(q, m_{j-1})$. Multi-context GRPO samples groups of full trajectories, calculates a trajectory-level reward and advantage, propagates this scalar advantage uniformly across all turns within the trajectory, and optimizes each conversation step as an independent training target.
  3. Loss Masking & Rewards: Tokens generated by the search engine are masked out during optimization. Rewards consist of a format-validity check and an exact-match/F1 answer accuracy reward relative to ground truth.

Datasets

  • Training: The training splits of Natural Questions (NQ) (single-hop general QA) and HotpotQA (multi-hop QA), using the same training recipe as Search-R1 with a 2018 Wikipedia knowledge dump and an E5 retriever.
  • Evaluation: Evaluated across seven public benchmarks spanning both in-distribution and out-of-distribution tasks:
  • General / Factual QA: Natural Questions (NQ), TriviaQA, PopQA.
  • Multi-Hop QA: HotpotQA, 2WikiMultiHopQA, Musique, Bamboogle.

Key Insights and Ideas

  • Memory Management Can Be Learned via RLVR: Off-the-shelf instruct models fail at MemSearcher out of the box (e.g., Qwen2.5-3B achieves only 14.4% average Exact Match without training). Reinforcement learning via verifiable rewards (RLVR) successfully incentivizes the model to balance reasoning, querying, and concise summarization simultaneously without requiring human-curated memory-updating demonstrations.
  • Two-Phase Learning Dynamics: Training curves show that agents first master the syntax and basic tool/memory mechanics within ~25 steps, followed by a gradual refinement stage where multi-hop search strategies and summarization precision are tuned.
  • Smaller Models Win with Cleaner Contexts: By eliminating noisy context buildup, a 3B MemSearcher agent outperforms 7B ReAct models, demonstrating that context quality often matters more than raw parameter scale for multi-turn agentic workflows.

Key Results

  • Accuracy Improvements: MemSearcher consistently outperformed baselines across all 7 benchmarks:
  • Qwen2.5-3B-Instruct: MemSearcher achieved 43.8% average Exact Match (EM), compared to 32.5% for Search-R1 and 39.6% for AutoRefine (+11% relative gain).
  • Qwen2.5-7B-Instruct: MemSearcher reached 48.9% average EM, outperforming Search-R1 (38.5%) and ReSearch (43.6%) (+12% relative gain).
  • Notably, 3B MemSearcher (43.8%) beat 7B baselines like Search-R1 (38.5%) and ReSearch (43.6%).
  • Token Stability: While ReAct contexts expanded almost linearly past 14k+ tokens by Turn 10, MemSearcher maintained a flat, low token count (~2k tokens per turn), drastically reducing peak GPU memory usage and preventing out-of-memory (OOM) errors during long interactions.

Limitations and Future Work

  • Coarse Advantage Assignment: Multi-context GRPO assigns the final trajectory-level advantage uniformly across every turn. Credit assignment could be improved by evaluating the quality or contribution of individual memory updates and search actions.
  • Fixed-Capacity Natural Language Memory: The memory buffer is constrained to a static maximum token limit (1,024 tokens). On extremely long-horizon tasks requiring dozens of retrieval steps, crucial details could eventually be compressed away.
  • Evaluation Scope: Experiments were conducted using a static local Wikipedia corpus; evaluating MemSearcher on live, open-web search environments remains an open next step.

Summary updated

BibTeX
@misc{yuan2025memsearcher,
  author = {Qianhao Yuan and Jie Lou and Zichao Li and Jiawei Chen and Yaojie Lu and Hongyu Lin and Le Sun and Debing Zhang and Xianpei Han},
  title = {{MemSearcher: Training LLMs to Reason, Search and Manage Memory via End-to-End Reinforcement Learning}},
  year = {2025},
  eprint = {2511.02805},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2511.02805},
}
Figure