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

Source: [arXiv](https://arxiv.org/abs/2607.05378v1)  
Feed7 permalink: https://feed7.dev/p/2607-05378v1-0j3vikd  
Published: Unknown  
Trust: Needs Review (needs_review)

## Why Included

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.

## 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

- Layer: agent
- Domains: coding, research
- Topics: 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.

## Agent Instruction

Use this item as source-backed context. Do not invent claims beyond the linked source. If this item conflicts with another source, call out the conflict.
