What is context compaction, and when do you reach for it?
Quick-fire answer from the Awesome Generative AI Guide (MIT)
Type it the way you would explain it to an interviewer. A few sentences is enough; you can't break anything.
Model answer: the part to lead with
Compaction is periodically replacing a long, accreted context (many turns of messages and verbose tool results) with a shorter summary that preserves the decisions, facts, and open goals the agent still needs. You reach for it in long-horizon agent loops that would otherwise exhaust the window or suffer context rot, and in multi-turn chats where old detail no longer changes the next action. The risk is dropping a detail that mattered, so you compact deliberately: keep recent turns and key artifacts verbatim, summarize the rest, and store anything durable in external memory you can re-retrieve. Done well it cuts cost and latency and improves reliability by removing distracting noise.
Full worked answer
Compaction is periodically replacing a long, accreted context (many turns of messages and verbose tool results) with a shorter summary that preserves the decisions, facts, and open goals the agent still needs. You reach for it in long-horizon agent loops that would otherwise exhaust the window or suffer context rot, and in multi-turn chats where old detail no longer changes the next action. The risk is dropping a detail that mattered, so you compact deliberately: keep recent turns and key artifacts verbatim, summarize the rest, and store anything durable in external memory you can re-retrieve. Done well it cuts cost and latency and improves reliability by removing distracting noise.
Learn more: Anthropic: Effective context engineering for AI agents
What a good answer covers
- Compaction is periodically replacing a long, accreted context (many turns of messages and verbose tool…
- You reach for it in long-horizon agent loops that would otherwise exhaust the window or suffer context…
- The risk is dropping a detail that mattered, so you compact deliberately
- Done well it cuts cost and latency and improves reliability by removing distracting noise
Key terms: Learn more
In the glossary: Compaction · Context rot · Context engineering
Quick-fire answer from the Awesome Generative AI Guide (MIT) · answer text last updated 6 November 2026 · scoring and review schedule by LLM Prep