Research
MemSearcher: Training LLMs to Reason, Search and Manage Memory via End-to-End Reinforcement Learning
Overview Research area: Natural Language Processing — LLM-based search agents and reinforcement learning for agentic tool use. Technical level: Advanced (requires familiarity with reinforcement learni
- arXiv
- 2511.02805
- Published
- 2025-11-04
- Authors
- Qianhao Yuan, Jie Lou, Zichao Li, Jiawei Chen, Yaojie Lu, Hongyu Lin, Le Sun, Debing Zhang, Xianpei Han
AI summary
Overview
Research area: Natural Language Processing — LLM-based search agents and reinforcement learning for agentic tool use.
Technical level: Advanced (requires familiarity with reinforcement learning, policy optimization, and LLM agent frameworks).
Scope: This paper proposes a memory-centric search agent framework and a modified GRPO training algorithm that keeps LLM context size constant across multi-turn search interactions while outperforming standard ReAct-style history-concatenation agents.
What This Paper Is About
Search agents built on the ReAct paradigm append every thought, tool call, and retrieved passage into the LLM's context, so the input grows linearly with each interaction turn — producing long, noisy, retrieval-heavy prompts that are expensive to run and hard for the model to reason over. This paper asks whether an agent can instead maintain a small, iteratively rewritten memory that keeps only question-relevant facts, and whether such an agent can be trained end-to-end with reinforcement learning when each turn of a trajectory occurs under a different context.
Key Contributions
- The MemSearcher framework: An agent design in which the backbone LLM receives only the user's question plus a compact natural-language memory (capped at a fixed maximum length, default 1,024 tokens) at each turn. After each tool response, the same LLM acts as a memory manager that rewrites the memory, overwriting rather than appending. This keeps per-turn context at O(1) and total compute linear in the number of turns, versus O(n) context and O(n²) total FLOPs for ReAct.
- Multi-context GRPO: Because each turn in a MemSearcher trajectory has its own distinct context, vanilla GRPO — which treats a whole trajectory as one optimization target — does not directly apply. The paper generalizes GRPO by computing the trajectory-level advantage, propagating that single scalar to every turn inside the trajectory, and then treating each turn as an independent policy-gradient target with its own importance ratio.
- A verified training recipe: A two-part rule-based reward (format reward for correct tag usage and boxed answer presence; answer reward based on F1 against ground truth) with a graded scheme that gives partial credit for well-formatted but wrong answers, plus loss masking on search-engine tokens.
- Empirical validation at three model scales: Experiments on Qwen2.5-3B/7B/14B-Instruct across seven public QA benchmarks, showing performance gains over ReAct-based RL agents and near-constant token counts across turns.
Main Findings
- MemSearcher beats ReAct-style baselines across all seven benchmarks. Average exact-match scores: 43.8 (3B), 48.9 (7B), and 51.7 (14B), compared against the strongest baselines in each size class.
- Small MemSearcher models outperform much larger baselines. The 3B model's 43.8 average exceeds every 7B baseline tested, and the 7B model's 48.9 average edges out ReSearch 32B (48.3). The authors interpret this as more effective use of model capacity rather than raw scale.
- Context length stays nearly flat across turns. Measured against ReAct-based ReSearch, which shows the expected linear token growth, MemSearcher holds steady. Multi-turn interactions fit within a window under 4K tokens.
- It also outperforms agents using live Google Web Search. MemSearcher, which uses a 2018 Wikipedia dump with an E5 retriever, beats ZeroSearch and R1-Searcher, both of which query the real web during evaluation.
- RL training is essential — the framework alone is not enough. The same models run inside MemSearcher but without RL drop sharply across every benchmark (e.g., 14.4 average for Qwen2.5-3B-Instruct versus 43.8 after training).
- RL beats supervised fine-tuning. On Qwen2.5-3B-Instruct, RL reaches 43.8 average versus 28.5 for distillation-based SFT from Qwen2.5-72B-Instruct. The authors argue SFT requires expensive annotations of intermediate memory states and relies on teachers that were never optimized for the MemSearcher role.
- Memory length has a sweet spot. Ablating from 256 to 2,048 tokens shows intermediate values work best. Simple datasets like Bamboogle saturate at 256 tokens, while complex multi-hop datasets like Musique keep improving up to 1,024 tokens.
- Training shows two distinct learning phases. Reward rises sharply in the first ~25 steps (acquiring basic search-and-memory skills), then grows gradually (refining strategy).
Methodology in Plain English
The researchers reframe the agent's job. Instead of a running transcript of everything that has happened, the model gets two things each turn: the question and a short written note-to-self. It thinks, picks an action (search or answer), gets a result from the search engine, and then rewrites the note — keeping what still matters and dropping what doesn't. Because the note is capped in length, the prompt never balloons.
Training such an agent is awkward with standard RL. Normally, GRPO samples several complete attempts at a question, scores each one, and pushes the model toward the better attempts. But here, "one attempt" is really a chain of separate model calls, each made under a different context. You can't just treat the whole chain as one action sequence.
The fix: score the whole attempt, compute how much better it did than the group average, and then hand that same score to every turn in the attempt — including turns that happened early, before any mistakes became apparent. Each turn is then optimized on its own, as if it were a standalone example. Tokens produced by the search engine are masked out of the loss so the model is only credited or blamed for what it actually generated.
Rewards are simple and rule-based: wrong format gets nothing, correct format but wrong answer gets 0.1, and a correct answer gets its F1 score against the reference. Experiments use Qwen2.5 at 3B, 7B, and 14B, trained on the open NQ and HotpotQA training splits with 8 H100 GPUs (16 for the 14B model).
Why This Matters
This work attacks a practical bottleneck in agentic AI: the cost of long contexts. Retrieval-heavy agent trajectories are dominated by passages that turn out to be irrelevant, and both the compute bill and the GPU memory footprint scale quadratically with the number of turns. Demonstrating that an agent can learn what to forget via RL — and that this learned compression outperforms brute-force context accumulation — shifts the design space for agent architectures.
Real-world applications:
- Resource-constrained deployment: A search agent that runs inside a sub-4K-token window can serve on smaller GPUs or edge hardware where ReAct-style agents would be infeasible.
- Long-horizon research and investigative assistants: Any task requiring dozens of search steps (literature review, competitive intelligence, legal research) benefits from context that stays flat instead of degrading.
- Customer support and enterprise QA: Multi-hop questions over internal knowledge bases where noise from retrieved documents is the primary failure mode.
- Cost-sensitive production agents: Linear rather than quadratic compute scaling directly reduces serving cost as interaction depth grows.
Industry relevance: The result that a 3B model trained this way beats 7B baselines matters commercially — smaller models mean lower latency and lower serving cost. The fact that it also outperforms agents querying live Google Search suggests the gains come from better context management, not better retrieval infrastructure, which is a cheaper lever to pull.
Future Directions
- Richer memory representations. The paper uses a flat natural-language memory. The authors explicitly flag RAG-style external memory and structured memory (knowledge graphs, atomic memory units) as unexplored alternatives that might be learned rather than hand-designed.
- Length bias in multi-context GRPO. Propagating one trajectory-level advantage to every turn is a coarse credit assignment. Turns that are individually good but part of a failed trajectory get penalized, and long trajectories contribute more terms to the loss. The authors note that techniques to mitigate this bias remain open.
- Scaling to other agentic domains. The evaluation is confined to question answering over Wikipedia. Whether the memory-manager role transfers to code execution, web navigation, or multi-tool environments is untested.
- Better credit assignment across turns. Distinguishing which specific turn caused a trajectory to succeed or fail — rather than broadcasting a single scalar — is the natural next algorithmic step.
Target Audience
Researchers and engineers working on LLM agents, tool-use reinforcement learning, or long-context inference efficiency. The paper will be most useful to those already familiar with GRPO or PPO and with the ReAct agent paradigm, since the core algorithmic contribution (multi-context GRPO) assumes that background. Practitioners deploying search agents in production will find the efficiency results directly actionable even without following the RL derivation in detail.
Authors’ abstract
LLM-based search agents often concatenate the full interaction history into the context, producing long and noisy inputs, and increasing compute cost and GPU memory overhead. To address this issue, we propose MemSearcher, an agent framework that maintains a compact memory during multi-turn interactions, retaining only question-relevant information and thereby keeping the context length stable across turns. Training MemSearcher is challenging because each trajectory spans multiple turns under different LLM contexts, making each turn an independent optimization target in reinforcement learning. We introduce multi-context GRPO, which propagates trajectory-level advantages to all turns for end-to-end optimization. Experiments demonstrate that MemSearcher outperforms strong history-concatenation (ReAct-style) baselines on a range of public datasets while maintaining nearly constant token counts across multi-turn interactions. The code and models will be publicly available at https://github.com/icip-cas/MemSearcher