← All notes

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

Sources

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

Permanent ID: iil:note:8dfag3n1

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.},
}

Markdown

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.