
Context Compression refers to techniques that reduce the effective token count of information passed to language models while preserving semantic meaning. As context windows expand to 1M+ tokens (Claude Opus 4.6, GPT-5.4), managing context efficiently becomes critical for both cost and performance. Approaches include two-tier history compression (used by the Lumen browser agent to maintain long browsing sessions without degradation), semantic caching, attention-based summarization, and structured state representations that replace verbose conversation history with compact state objects. Context compression is especially important for agentic workflows where multi-step task execution can quickly exhaust even million-token context windows through accumulated tool call/response pairs.
Why it matters
Even with million-token context windows, unmanaged context growth is a practical bottleneck for AI agents. Each tool call adds both the request and the full response to the conversation history. A browser automation agent accumulating page contents, a code analysis agent reading file after file, or a research agent gathering documents from multiple sources can exhaust their context window in dozens of steps. Beyond hard limits, performance degrades as context grows — models lose focus on relevant information buried in lengthy histories. Cost scales linearly with token count, making uncompressed agentic workflows prohibitively expensive at scale. Context compression is the engineering discipline that makes sustained multi-step agent operation economically and technically viable.

How it works
Several complementary techniques exist. Two-tier history compression, as used by the Lumen browser agent, divides context into a short-term working memory (recent actions and observations) and a long-term compressed summary (key findings and decisions from earlier steps). Semantic caching stores frequently accessed information so it does not need to be re-retrieved or re-processed. Attention-based summarization uses the model itself to distill verbose tool outputs into essential information before adding them to context. Structured state representations replace free-form conversation history with compact JSON state objects that capture the current situation without the full narrative. These techniques can be combined — for example, compressing older history while keeping recent steps verbatim.
Example
A browser automation agent on a 50-step research task demonstrates the impact. Without compression, accumulated page contents, navigation history, and extracted data would exceed 2 million tokens by step 30 — well beyond any context window. With two-tier compression, the agent maintains a compact summary of key findings from steps 1-25 (roughly 2,000 tokens) while keeping the full detail of the last 5 steps (roughly 50,000 tokens). This keeps the active context under 200K tokens while preserving all information needed for the current step. The research quality remains high because the compressed summary captures the essential facts and relationships, while recent context provides the detail needed for immediate decisions.