TL;DR
REMORY is a neural memory network that prevents long-horizon agents from "forgetting" critical details during context compaction. By supplementing lossy textual summaries with learned "soft memory tokens," it allows models to approach full-context performance using just 5% of the original input length, significantly reducing tool errors and improving source attribution.
What Problem Does This Paper Address?
Modern LLM agents are often tasked with complex, multi-step projects (coding, web research, etc.) that quickly exceed their finite context windows. To keep working, these agents must "compact" their history—usually by replacing a long transcript of past actions with a concise textual summary.
The authors identify a major flaw in this "sawtooth" pattern of context growth and reduction: textual summaries are inherently lossy. A summary that captures the "main thread" might inadvertently discard a specific error code or a file path that becomes crucial ten steps later. This leads to a performance gap where the agent has a "checkpoint" to resume from but lacks the nuanced "residual" information needed for optimal decision-making.
Methods
The core innovation is REMORY, a neural memory network that generates a bounded sequence of "soft tokens" (vectors in the LLM's embedding space) to supplement the textual summary.
The process works as follows:
- Conditioning: When context is compacted, REMORY takes the full history ($H_i$) and the newly generated summary ($S_i$).
- Generation: It produces a sequence of memory vectors ($M_i$) that are appended to the summary.
- Residual Connection: The authors call this "residual memory" because the soft tokens act like a residual connection along the sequence dimension, providing the "delta" of information that the summary missed.
Training happens in two stages using a frozen "actor" LLM:
- Stage I (Reconstruction): The network learns to compress a source passage into soft tokens such that the frozen LLM can reconstruct the original text.
- Stage II (Continuation): Using a teacher-student setup, the student (summary + REMORY) tries to match the next-token probability distribution of the teacher (full history). This forces the memory tokens to prioritize information that actually helps predict the agent's next move.
Datasets
The authors utilized a mix of reasoning and coding trajectories for training and a diverse suite of benchmarks for evaluation:
- Training: Text fields from
MMFineReason-Full-2.3Mand reasoning trajectories fromOpen-PerfectBlend. - Evaluation:
- SummHay: A "needle-in-a-haystack" style benchmark for long-document insight recovery and source attribution.
- Agent Benchmarks:
BrowseComp(web research),Terminal-Bench 2.1(CLI tasks),AutomationBench(business workflows), andJobBench(professional tasks).
Key Insights and Ideas
- Associative Memory over Raw Coverage: On the SummHay benchmark, REMORY didn't just find more facts; it significantly improved source attribution (Citation F1). This suggests the memory tokens act as an "index," helping the model link recovered claims back to their supporting evidence in the original documents.
- Efficiency via Soft Tokens: REMORY achieved a joint score on SummHay nearly identical to the "Raw Context" baseline (43.39 vs 43.41) while using only 5.2% of the input positions. This represents a massive efficiency gain for long-horizon tasks.
- Biological Parallel: The authors draw an analogy to human cognition, where the prefrontal cortex handles the active workspace (the summary) while the hippocampus provides an index to reinstate distributed representations of earlier experiences (the residual memory).
Key Results
The intervention showed consistent gains across different model families (Qwen3.8-27B and GLM-5.3-Flash):
- Benchmark Scores: On
Terminal-Bench 2.1, Qwen's score jumped from 71.9% to 76.4%. GLM-5.3-Flash saw similar gains, pushing it closer to frontier-level models like GPT-5.6-Sol. - Reliability: One of the most striking results was the reduction in "agentic friction." Models using REMORY exhibited 17.9–29.8% fewer repeated tool outputs and 25.3–49.7% fewer tool errors. This indicates the memory helps agents realize when they are stuck in a loop or repeating a failed command.
- Cost Savings: Because the compacted context is much smaller than the full history, generation costs fell in almost every comparison, despite the added memory tokens.
Limitations and Future Work
- Attribution Ambiguity: While the case studies (like the "Cell Segmentation" task in Figure 5) show agents successfully recovering from errors after compaction, it is difficult to mathematically prove exactly which specific detail was retrieved from the "soft" memory versus the textual summary.
- Teacher Dependence: Training REMORY requires a "teacher" model that can process the full context, which may be computationally expensive for extremely long horizons.
- Future Directions: The authors suggest exploring how this residual formulation could interact with explicit file-retrieval tools or hierarchical memory structures for even longer-term autonomy.
Summary updated