Context Compaction
Definition
Context compaction replaces or removes accumulated interaction state while preserving the information needed for subsequent decisions. Typical forms include rolling summaries, retaining only recent turns, dropping bulky tool payloads, and returning compact verifier results. GoDaddy combines summaries, extracted entities, recent turns, and tool-result removal; Hex compacts before the window is technically full because excessive context itself degrades behavior. GoDaddy Hex
Corpus Support
The analysis counts 98 deduplicated agentic systems (9.9%) across 10 industries. Evidence includes 61 article, 83 transcript, and 12 summary quotes, all 156 labeled stated. Corpus analysis
Problem It Solves
Long-running agents accumulate dialogue, plans, tool results, logs, and intermediate artifacts until cost, latency, or model quality degrades. OpenGov retains rolling summaries plus recent messages, and Spotify's verification tools return only relevant errors or a short success result. OpenGov Spotify
Applicability Signals
- A workflow spans enough turns to approach context or latency limits. Hex
- Tool results are much larger than the decisions they support. Spotify
- Conversation history must survive while old wording can be summarized. OpenGov
- Specialized agents can reduce the tool and instruction surface per step. Doctolib
Architecture and Variants
- Rolling summary: replace older turns with a maintained task summary and retain recent messages verbatim. OpenGov
- Entity-plus-recency state: preserve extracted entities, a summary, and a bounded recent window. GoDaddy
- Proactive compaction: compact before the hard token limit when behavior starts degrading. Hex
- Compact tool feedback: return the smallest actionable verifier output rather than full logs. Spotify
Why Teams Choose It
Compaction extends useful run length and controls cost without requiring every downstream call to replay full history. It can also improve attention by removing resolved or irrelevant detail, not merely fit a token ceiling. Hex Spotify
Tradeoffs
- Summaries save space but can omit details needed later. OpenGov
- Keeping raw recent turns preserves local fidelity but makes the retained window arbitrary. GoDaddy
- Splitting work among specialists reduces context size but adds routing and handoff complexity. Doctolib
Gotchas and Resolutions
- Waiting until the context window is full can be too late because quality degrades before capacity is exhausted; compact on measured behavior and budget. Hex
- Removing tool output without retaining decisions can break later reasoning; preserve actionable conclusions and references. Spotify
- Repeated summarization can compound omissions; keep durable source artifacts outside the compacted prompt. OpenGov
When Not to Use It
Do not compact a short interaction whose exact wording is required, or use lossy summaries as the system of record. Compaction is unnecessary when a deterministic reference to an external artifact is cheaper and more faithful than reproducing it in context. Spotify
Boundaries and Related Patterns
context-engineering governs the entire information assembly process; compaction is specifically the reduction of accumulated state. agent-memory controls persistent retention and recall, while compaction changes what is active now. Specialized-agent decomposition may reduce context pressure but is not itself compaction. Doctolib
Operational Checklist
- Define what must remain verbatim, what may be summarized, and what may be dropped. GoDaddy
- Trigger compaction from measured tokens, latency, and quality rather than only the hard limit. Hex
- Keep durable references to full source artifacts outside active context. Spotify
- Test whether post-compaction agents can recover prior constraints and decisions. OpenGov
Representative Implementations
| Project | Industry | Implementation | Provenance | Source |
|---|---|---|---|---|
| GoDaddy support | E-commerce | Summary, entities, recent turns, and removed tool payloads. | source-backed | source |
| Hex data agents | Tech | Proactive compaction before context saturation. | source-backed | source |
| OpenGov assist | Government | Rolling summaries plus recent messages. | source-backed | source |
| Doctolib care agents | Healthcare | Specialized agents narrow prompt and tool scope. | source-backed | source |
| Spotify background agents | Media & Entertainment | Compact verifier feedback instead of full logs. | source-backed | source |
| Rippling GTM agents | HR | Scoped agent context over operational data. | source-backed | source |
Methodology and Limitations
This page samples 98 deduplicated systems. Reports usually describe a compaction mechanism without controlled comparisons of information loss, so operational guidance remains evidence-backed synthesis rather than a measured optimum. Corpus methodology