The Compress Strategy: Beating Context Rot

The Compress Strategy: Beating Context Rot

The Compress Strategy: Beating Context Rot Without Losing What Matters

Compression is where the largest untapped gains usually hide. Most teams over-invest in retrieval and under-invest here. Yet for any long interaction, compression is what keeps context from degrading into rot.

Ask experienced practitioners where the biggest easy wins in context engineering are, and many point to compression. It is the least glamorous of the four strategies, the one teams most often neglect, and frequently the one with the most headroom. For any agent or conversation that runs long, compression is what prevents the context window from filling with verbose history and degrading into context rot.

The Core Technique: Summarisation

The fundamental compression technique is summarisation: replacing a long stretch of context with a shorter version that retains the essential information. This applies to conversation history (summarise twenty turns into a paragraph), to tool outputs (replace a verbose API response with its key fields), and to retrieved documents (condense to the passages that matter). Done well, it keeps context lean while preserving the thread.

Context Engineering: The Complete Guide

Want compression covered with all its techniques?

40 pages covering the four core strategies, the context window anatomy, all four failure modes, RAG, memory systems, multi-agent isolation, 20 production patterns and a complete 30-day mastery plan.

Get the Complete Guide →

When to Trigger Compression

Compression can fire at different triggers. Some systems compress when context reaches a threshold, say 75% of the window. Others compress on a schedule, every N turns. Others compress opportunistically at natural boundaries. The right trigger depends on the task, but the principle is constant: do not let raw history accumulate indefinitely. The Anthropic finding is instructive: sessions that stopped at 75% utilisation produced higher-quality output than those pushed to the limit.

Structured Compression

Naive summarisation risks discarding something important. Structured compression mitigates this by preserving information in a defined schema rather than free-form prose. Instead of summarising a conversation into a paragraph that might omit a key constraint, you compress it into a structure with explicit fields: decisions made, constraints established, open questions, key facts. The structure ensures the load-bearing information survives the compression.

Auto-Compaction in Practice

Auto-compaction is automated compression that triggers as context approaches a limit. Claude Code uses this: when conversation grows long, it automatically summarises earlier portions to free space while preserving the thread. The agent continues with a compacted version of its history rather than hitting a wall or degrading. Implementing it means defining when to trigger, what to compress (usually the oldest, least relevant content), and how.

Avoiding the Lossy Traps

The danger of compression is losing something you needed. Summarising away a constraint the user established early ("we must support IE11") leads the agent to violate it later. Compressing tool outputs too aggressively discards a detail a later step needs. The defence is to identify load-bearing information, constraints, decisions, key facts, user preferences, and protect it explicitly, even structuring your compression to always retain these categories. Compress the conversational padding aggressively; compress the load-bearing content carefully or not at all.

Ready to engineer context deliberately?

Context Engineering: The Complete Guide covers everything: the anatomy of a context window, the four core strategies (Write, Select, Compress, Isolate), RAG and memory systems, multi-agent isolation, the four failure modes and how to diagnose them, what the research says about formats, 20 production patterns, 12 common pitfalls, and a 30-day plan that takes you from the concepts to real production systems.

Get the Complete Guide →

Instant PDF download · 40 pages · Current as of 2026