RECAP: Training Long-horizon LLM Agents with Context Compaction
Yulun Jiang, Maria Brbic, Michael Moor
Key points
From the paper's conclusion- We introduce RECAP, a reinforcement learning (RL) framework based on the principle that a summary should preserve the behavior induced by the original interaction history.
Abstract
Context compaction enables large language model agents to tackle long-horizon tasks within limited context budgets by replacing interaction histories with compressed summaries. However, learning effective compaction jointly with the agent policy remains challenging, as summaries affect task success over many subsequent interactions. We introduce RECAP, a reinforcement learning (RL) framework based on the principle that a summary should preserve the behavior induced by the original interaction history. We formalize this principle with a behavior distortion objective that measures the divergence between the agent's subsequent behavior under compressed and original contexts. We show that the gradient of the distortion objective decomposes into two complementary learning signals: distortion-based reward for summary generation and self-distillation for subsequent actions. Experiments on Qwen3.5-4B show that RECAP consistently outperforms the task-reward-only RL baselines on both environments, leading to an absolute improvement of 4.6% and 4.3% on BrowseComp-plus and SWE-bench Verified, respectively. Ablations further highlight the value of jointly supervising summary generation and post-compaction behavior for RECAP.
Read the paper
Discussion
Science Skim's AI key points, plus readers' public thoughts
Readers' thoughts
No reader thoughts yet.
Related papers
- Persistent Context Graphs for Efficient Memory Compaction in LLM AgentsarXiv · 2026
- SUMONE: A Simple and Efficient Summarizer for Plug-and-Play Agent MemoryarXiv · 2026
- Prune the Summary, Not the History: Source-Judged Compaction for Long-Horizon AgentsarXiv · 2026
- SpecCompact: Accelerating LLM Agent Context Compaction with Slot-Parallel Semantic Speculative VerificationarXiv · 2026
- ContextPilot: Teaching Agents for Proactive Context Management via Fine-grained RLarXiv · 2026
- Bud ContextCompact 2.0: Context Compaction for Agent Success and Accuracy with Small Language Models and Constrained Context WindowsarXiv · 2026