CompactionRL: Reinforcement Learning with Context Compaction for Long-Horizon Agents
作者: Yujiang Li, Zhenyu Hou, Yi Jing, Jie Tang, Yuxiao Dong
分类: cs.LG
发布日期: 2026-07-06
💡 一句话要点
提出CompactionRL以解决长时间跨度强化学习中的上下文限制问题
🎯 匹配领域: 支柱二:RL算法与架构 (RL & Architecture)
关键词: 长时间跨度 强化学习 上下文压缩 大语言模型 智能代理 任务执行 摘要生成
📋 核心要点
- 现有长时间跨度的智能代理模型受到有限上下文窗口的限制,导致任务执行效率低下。
- CompactionRL通过上下文压缩和联合优化任务执行与摘要生成,提升了长时间跨度的学习能力。
- 在多个编码任务上,CompactionRL显著提高了模型的性能,GLM-4.5-Air模型在SWE-bench Verified上达到了66.8%的Pass@1分数。
📝 摘要(中文)
长时间跨度的智能代理大语言模型(LLMs)受到有限上下文窗口的限制,导致在任务完成前,交互轨迹可能超出最大上下文长度。上下文压缩通过总结先前的交互状态并在压缩上下文下继续执行,提供了一种自然的解决方案。然而,将压缩方法融入强化学习的研究仍然较少。本文提出了CompactionRL,一种用于训练长时间跨度智能代理LLMs的强化学习策略。该方法通过令牌级损失归一化和跨轨迹广义优势估计,联合优化任务执行和摘要生成,使LLM代理能够从压缩的长时间跨度轨迹中学习。实验表明,CompactionRL在开放模型上训练时,在智能编码任务上表现出一致的性能提升。
🔬 方法详解
问题定义:本文旨在解决长时间跨度强化学习中上下文窗口有限的问题,现有方法在处理长交互轨迹时容易超出最大上下文长度,影响任务完成效率。
核心思路:提出CompactionRL,通过上下文压缩技术,结合任务执行与摘要生成的联合优化,增强模型在长时间跨度任务中的学习能力。
技术框架:CompactionRL的整体架构包括上下文压缩模块、任务执行模块和摘要生成模块,采用令牌级损失归一化和跨轨迹广义优势估计来优化学习过程。
关键创新:最重要的创新在于将上下文压缩与强化学习相结合,允许模型在压缩的上下文中继续学习,从而有效应对长时间跨度的任务。
关键设计:在损失函数设计上,采用令牌级损失归一化以平衡不同任务的学习效果,同时引入跨轨迹广义优势估计来提高学习的稳定性和效率。
🖼️ 关键图片
📊 实验亮点
CompactionRL在多个实验中表现出色,GLM-4.5-Air模型在SWE-bench Verified上达到了66.8%的Pass@1分数,相较于基线提升了7.0分;在Terminal-Bench 2.0上也提升了3.1分。GLM-4.7-Flash模型的表现同样显著,Pass@1分数分别提升了5.5和6.8分。
🎯 应用场景
CompactionRL的研究成果在智能代理、自动编码、自然语言处理等领域具有广泛的应用潜力。通过提升长时间跨度任务的执行效率,该方法能够为复杂的交互系统提供更高效的解决方案,推动智能系统的实际应用和发展。
📄 摘要(原文)
Long-horizon agentic LLMs are increasingly limited by finite context windows, as extended interaction trajectories can exceed the maximum context length before a task is completed. Context compaction offers a natural solution by summarizing previous interaction states and continuing the rollout under a compressed context, but incorporating compaction into reinforcement learning remains underexplored. We propose CompactionRL, a reinforcement learning strategy to train long-horizon agentic LLMs with context compaction. Our approach jointly optimizes task execution and summary generation with token-level loss normalization and cross-trajectory generalized advantage estimation. This design enables the LLM agents to learn from compacted long-horizon trajectories. We train CompactionRL on top of open models and observe consistent performance gains on agentic coding tasks. CompactionRL enables the open GLM-4.5-Air model (106B-A30B) to achieve Pass@1 scores of 66.8% on SWE-bench Verified and 24.5% on Terminal-Bench 2.0, with absolute gains of 7.0 and 3.1 points, respectively. Built upon GLM-4.7-Flash (30B-A3B), CompactionRL improves Pass@1 by 5.5 and 6.8 points, reaching 56.0% on SWE-bench Verified and 20.2% on Terminal-Bench 2.0, respectively. CompactionRL is thus deployed in the RL pipeline for training the open GLM-5.2 model (750B-A40B).