When should a coding agent compact its context?
Short answer
Not only when the window overflows. In long coding tasks earlier exploration goes stale, so compaction is a decision about timing and about which working state to keep. AutoCompact trained an agent to make that decision itself and raised pass rates on SWE-bench Verified and SWE-PolyBench Verified. [S1] Memory design more broadly is the key component for agents that interact with environments over long periods. [S2]
Claims
- id: C1 claim: Earlier exploration becomes stale as a coding task progresses. source: S1 evidence: "As a task progresses, earlier exploration becomes stale"
- id: C2 claim: AutoCompact trains the agent to make compaction decisions in its policy. source: S1 evidence: "We introduce AutoCompact, which trains a coding agent to make these decisions as part of"
- id: C3 claim: Gains held across all evaluated inference budgets. source: S1 evidence: "The improvements hold across all evaluated inference budgets"
- id: C4 claim: Memory is the key component for agent-environment interaction. source: S2 evidence: "The key component to support agent-environment interactions is the memory of the agents."
Sources
- [S1] [2610.02163] AutoCompact: Learning When to Compact Context in Long-Horizon Coding Agents. arXiv. https://arxiv.org/abs/2610.02163 . License: CC BY 4.0. Accessed 2026-11-04.
- [S2] [2404.13501] A Survey on the Memory Mechanism of Large Language Model based Agents. arXiv. https://arxiv.org/abs/2404.13501 . License: CC BY 4.0. Accessed 2026-11-04.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted).
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: arXiv, [2610.02163] AutoCompact: Learning When to Compact Context in Long-Horizon Coding Agents, CC BY 4.0; arXiv, [2404.13501] A Survey on the Memory Mechanism of Large Language Model based Agents, CC BY 4.0.
Cite this
iinventedlight. 2026. "When should a coding agent compact its context?" iinventedlight Library, iil:note:8dfag3n1, version of 2026-11-04. https://iinventedlight.com/library/notes/ao-compaction-when-to-compact/. License: CC-BY-4.0.
@misc{iil_note_8dfag3n1,
author = {{iinventedlight}},
title = {{When should a coding agent compact its context?}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-04},
url = {https://iinventedlight.com/library/notes/ao-compaction-when-to-compact/},
note = {Permanent ID iil:note:8dfag3n1. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.
For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/ao-compaction-when-to-compact.md.