Home→Glossary→Compaction

Compaction

Compaction

Summarizing older turns to reclaim room in a filling context window

✓ Runtime & Session
Talk to AY Automate ↗
Lossy by natureTriggered near the token limitKeeps a session alive longer

What is Compaction

Compaction is what happens when a session's context window starts running out of room: instead of hitting a hard wall, older turns get condensed into a shorter summary, freeing space for the session to keep going. It is a deliberate tradeoff, some detail from the compacted portion is lost, in exchange for the session being able to continue at all.

This matters most on long sessions: an extended debugging effort, a multi-hour build, a research task that reads dozens of files. Without compaction, a session either has to stop the moment its window fills, or every new turn has to fight for shrinking room against a fixed and growing history. Compaction lets sessions run much longer than the raw token budget would otherwise allow.

Compaction is not the same as clearing a session, which discards history rather than summarizing it, and it is not free: whatever gets compressed away is genuinely gone in its original form, only the summary remains. This is why handoffs matter for anything that must survive with full fidelity, a compacted summary is good enough for most continuity but not a substitute for a deliberately written record of something important.

AY Automate

Build your own agent skills, not just prompts.

We design, build, and ship the Claude Code skill libraries production teams actually run on.

Talk to AY Automate ↗

Key properties

✓Summarizes, does not simply delete, older turns
✓Triggered automatically as the window nears its limit
✓Trades some detail for continued room to work