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.
REMORY: Learning Residual Memory for Context Compaction
Shanghai Academy of AI for Science(上海人工智能科学研究院);Fudan University(复旦大学);Shanghai Jiao Tong University(上海交通大学);University of Michigan(密歇根大学);The Chinese University of Hong Kong(香港中文大学);Alibaba Group(阿里巴巴集团);Nanjing University(南京大学);Shanghai Innovation Institute(上海创新研究院)
HaReCAP: Habitual-action Grounding for Recursive Large Language Model Agents
North China Institute of Computer System Engineering(华北计算机系统工程研究所);University of Science and Technology of China(中国科学技术大学);China Information Security Research Institute Co., Ltd.(中国信息安全研究院有限公司)
TokenPilot: Cache-Efficient Context Management for LLM Agents
Zhejiang University(浙江大学);University of Electronic Science and Technology of China(电子科技大学);Xi’an University of Electronic Science and Technology(西安电子科技大学);HomologyAI(同源人工智能)
LeafSkill: Efficient Leaf-Level Action Grounding for Recursive LLM Agents
North China Institute of Computer System Engineering(华北计算机系统工程研究所);Beijing University of Aeronautics and Astronautics(北京航空航天大学);University of Science and Technology of China(中国科学技术大学);China Information Security Research Institute Co., Ltd.(中国信息安全研究院有限公司)
Coding Agent Memory Post-Training II: Unlocking the Memory Potential of Pre-trained File Operations for Long-Horizon Tasks via On-Policy Distillation
Peking University(北京大学);Sichuan University(四川大学);Beijing Institute of Technology(北京理工大学);Renmin University of China(中国人民大学);The Hong Kong University of Science and Technology(香港科技大学)