When a coding agent runs a long task, its context only grows: inspecting files, running searches, editing code, executing tests. The trajectory piles up stale hypotheses, failed attempts, and verbose tool outputs. Today's mainstream harnesses — the paper names Codex and Claude Code — handle this with a length-triggered design: compact automatically as the context approaches the window limit. AutoCompact, posted to arXiv on October 1 by Xuan Zhang, Longtao Zheng and colleagues (Singapore Management University, Nanyang Technological University, and Harvard among the affiliations), moves that decision into the model's own policy: the agent learns when to compact, what to preserve, and how to continue afterwards.
The problem with "compact when full" is the "when"
Length-triggered compaction ties the decision to context length rather than task progress. The paper's observation is blunt: stale exploration keeps accumulating until a threshold fires, and that trigger can land in the middle of an unresolved stage — exactly when the evidence is most needed. Prior work did let models decide: rubric-based self-compacting agents at inference time, SWE-Compressor inserting compaction calls into completed trajectories offline, and CompactionRL folding compaction into an RL loop. But the authors point out a shared blind spot: none of them supervise the first action after compaction — even a correct working-state summary can be followed by the agent re-running a search whose result was already recorded.
An online judge that corrects, then executes
AutoCompact gives the agent a proactively invocable compact() action. During data collection, GPT-5.5-Codex serves as an online judge: at every step it reviews the proposed action — wrong compaction timing, a summary missing key state, a post-compaction step going off-track are all rewritten on the spot. Corrected outputs are executed in the environment directly, so the trajectory grows from the correction point. This differs fundamentally from post-hoc annotation: the correction genuinely changes later states. Across 379 SWE-rebench tasks the team collected 1,052 judge-corrected trajectories — 24% supervising triggers, 53% working-state construction, 23% continuation. SFT initializes the policy; GRPO on SWE-Gym then jointly optimizes coding and compaction with a single binary reward: whether the final patch passes the task's tests. No compaction-specific reward shaping.
The numbers: two benchmarks, two window regimes, gains across the board
The base model is Qwen3-Coder-30B-A3B-Instruct. Pass rate reaches 39.6% on SWE-bench Verified (+9.2 points absolute over base) and 24.5% on SWE-PolyBench Verified (+5.0); outcome RL adds a further 7.4 and 2.8 points over the SFT checkpoint. Two settings stand out. Under a 256K window, no trajectory ever hits forced compaction, yet the SFT variant still beats the full-history base — a complete history is not the optimal input even when it fits. Under a constrained 16K window where all methods share the same length-triggered fallback, the trained proactive compaction still leads. Gains hold across inference budgets from $0.10 to $4.00 per task, and are largest where budget is tightest: with the same trained checkpoint but compact() execution skipped, the $0.10 tier loses 19.9 points. Behaviorally, proactive compaction usage rises from 44.3% of tasks after SFT to 58.5% after RL, key-state omissions in summaries fall from 3.1% to 0.2%, and next-action omissions from 8.2% to 2.2%.
Summary self-consistency: a newly named weakness
The case study offers a sharp contrast. On task django-13809, the SFT summary faithfully records an unresolved syntax error, yet proposes to finish without further action — state and action contradict each other, and the run fails with a SyntaxError. The RL summary stays consistent with its recorded state and passes. The authors call this dimension summary self-consistency. The limitations are stated plainly: RL training used 32K-token sequences while evaluation ran at 256K context, with the gains resting on that short-train, long-evaluate transfer.
So what? Context management is shifting from harness plumbing into trainable model behavior — knowing when to compact is itself part of the capability. The paper validates a single scaffold, but the direction is clear: commercial coding agents that still hard-compact at the limit are handing a learnable decision to a threshold.
Reference: arXiv:2610.02163 (https://arxiv.org/abs/2610.02163)