Five-Layer Compaction Architecture
- Entity ID:
ent-20260419-c2d3e4f5a0b1 - Type:
concept - Scope:
shared - Status:
active - Aliases: 5-layer context compaction, tool-result-budget + snip + micro + auto + collapse, compaction-taxonomy-5
Description
The complete public taxonomy of Claude Code's context management (Layer 1 Tool Result Budget → Layer 2 HISTORY_SNIP Snip Compaction → Layer 3 Microcompaction → Layer 4 Autocompact → Layer 5 CONTEXT_COLLAPSE). Layers 1–3 are zero-cost in-process operations that truncate tool outputs or edit cached messages locally with no API call. Layers 4–5 are hidden API calls to a separate summarization model, producing a new cache chain invisible to the user. Layer 5 CONTEXT_COLLAPSE exists only in internal/employee builds and is feature-gated behind USER_TYPE==='ant'. This is more granular than prior 3-layer and 5-stage compression taxonomies in the extraction: it names the Tool Result Budget and Snip Compaction steps as distinct layers from Microcompaction.
Key claims
- Compaction has five layers, not two
- Autocompact threshold is a runtime GrowthBook flag, not a fixed value
- Compaction optimizes 'what to do next' and discards 'why we did what we did'
- Claude Code's context window is the binding resource constraint
- Five pre-model context shapers run sequentially before every model call
- Compaction reuses prompt cache via a GrowthBook flag
Relations
- Five-Layer Compaction Architecture --[contains]--> Tool Result Budget
- Five-Layer Compaction Architecture --[contains]--> HISTORY_SNIP Snip Compaction
- Five-Layer Compaction Architecture --[contains]--> CONTEXT_COLLAPSE (Layer 5 Emergency Compaction)
- Five-Layer Compaction Architecture --[supersedes]--> Compaction Pipeline
- compaction/ Directory --[implements]--> Five-Layer Compaction Architecture
- Graduated Lazy-Degradation Principle --[informs]--> Five-Layer Compaction Architecture
- Chain Patching via headUuid/anchorUuid/tailUuid --[implements]--> Five-Layer Compaction Architecture
- Conversations Outlive Context Principle --[motivates]--> Five-Layer Compaction Architecture
- OpenClaw Workspace Bootstrap File Set --[contrasts_with]--> Five-Layer Compaction Architecture
- Graduated Layering Over Monolithic Mechanisms --[informs]--> Five-Layer Compaction Architecture
- Context as Scarce Resource with Progressive Management (Principle) --[instantiated_by]--> Five-Layer Compaction Architecture