---
source: https://iinventedlight.com/library/notes/ao-compaction-when-to-compact.md
title: "When should a coding agent compact its context?"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC BY 4.0; restated in our own words"
attribution: "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."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-04
status: published
checked_on: 2026-11-04
as_of: 2026-11-04
confidence: medium
untested: "No experiment was run; only the fetched arXiv abstract pages were read, so results are as reported by the authors."
category: agent-operations
topic_area: "agent-ops: context compaction"
tags: agents, context-compaction, coding-agents
sources:
  - id: S1
    title: "[2610.02163] AutoCompact: Learning When to Compact Context in Long-Horizon Coding Agents"
    publisher: arXiv
    url: https://arxiv.org/abs/2610.02163
    accessed: 2026-11-04
    license: "CC BY 4.0"
  - id: S2
    title: "[2404.13501] A Survey on the Memory Mechanism of Large Language Model based Agents"
    publisher: arXiv
    url: https://arxiv.org/abs/2404.13501
    accessed: 2026-11-04
    license: "CC BY 4.0"
---
# 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).
