feed7.dev
Sign InStart Agent Brain
arXivPaperNeeds Review

CompactionRL: Reinforcement Learning with Context Compaction for Long-Horizon Agents

CompactionRL uses RL to teach agents to compact their own context mid-task, lifting GLM-4.5-Air 7 points to 66.8% on SWE-bench Verified; the recipe is now in GLM-5.2's training pipeline.

arXiv
Open Source Open MarkdownOpen JSON
Source Summary

**The gist** **CompactionRL** trains long-horizon agents to summarize their own trajectory and keep working under the compressed context, jointly optimizing execution and summary with token-level loss normalization and cross-trajectory advantage estimation. It lifts **GLM-4.5-Air to 66.8%** on SWE-bench Verified (**+7.0 points**) and 24.5% on Terminal-Bench 2.0, with GLM-4.7-Flash gaining **+5.5 and +6.8 points**.

Practical Implication

**Why it matters** Compaction today is a harness-side trick — the framework summarizes when the window fills, but the model was never trained to resume from its own summaries. **Training through compaction** teaches the model to write summaries that preserve what the task actually needs — a failure mode anyone running long coding-agent sessions has hit. The recipe already ships in the training pipeline of **GLM-5.2 (750B-A40B)**.

Agent-Ready Context
**The gist** **CompactionRL** trains long-horizon agents to summarize their own trajectory and keep working under the compressed context, jointly optimizing execution and summary with token-level loss normalization and cross-trajectory advantage estimation. It lifts **GLM-4.5-Air to 66.8%** on SWE-bench Verified (**+7.0 points**) and 24.5% on Terminal-Bench 2.0, with GLM-4.7-Flash gaining **+5.5 and +6.8 points**.

**Why it matters** Compaction today is a harness-side trick — the framework summarizes when the window fills, but the model was never trained to resume from its own summaries. **Training through compaction** teaches the model to write summaries that preserve what the task actually needs — a failure mode anyone running long coding-agent sessions has hit. The recipe already ships in the training pipeline of **GLM-5.2 (750B-A40B)**.

**Watch out** Gains are shown on **GLM models** and coding benchmarks (**SWE-bench Verified, Terminal-Bench 2.0**) only; whether trained compaction beats a well-engineered inference-time summarizer, or transfers beyond coding, isn't demonstrated.
Context Map
agentcodingresearch#context-engineering#coding-agents#open-models
Uncertainty
Gains are shown on **GLM models** and coding benchmarks (**SWE-bench Verified, Terminal-Bench 2.0**) only; whether trained compaction beats a well-engineered inference-time summarizer, or transfers beyond coding, isn't demonstrated.