Long-horizon agentic LLMs often run out of context before finishing a task. CompactionRL treats as a trainable part of the model rather than an inference-time heuristic, using PPO to jointly optimize task execution and summary generation. It introduces token-level loss normalization and cross-trajectory generalized advantage estimation to handle rollouts that are split into variable-length segments by compaction events.
On agentic coding benchmarks, CompactionRL improved GLM-4.5-Air by 7.0 points on SWE-bench Verified and 3.1 points on Terminal-Bench 2.0, reaching 66.8% and 24.5% Pass@1. Built on GLM-4.7-Flash, it gained 5.5 and 6.8 points, reaching 56.0% and 20.2%. The approach is already deployed in the RL pipeline for training GLM-5.2.
The key idea is that when a summary replaces part of the history, future actions depend on summary quality, so summaries should be learned from the task reward, not generated by a fixed heuristic. This extends effective training horizon without increasing the maximum working context length.