ConceptAgents & Tool Use
Context Compaction
At a glance
Summarizing older turns in an agent's context window so the next call keeps the right facts without the whole transcript.
- Who this is for
- Engineers and technical readers learning the terms used in AI systems.
- Topics
- Agents & Tool Use
- Concept
In short
Context compaction summarizes older turns in an agent's context window so the model keeps working without carrying the whole transcript. Bigcircle keeps recent turns verbatim, compacts older ones once they cross a threshold, and moves durable facts into agent memory. Deliberate compaction means deciding what to keep, what to summarize, and what to drop, which is part of week 1-3 of a harness engineering engagement.
Key facts
Definition
Context compaction summarizes older turns in an agent's context window and continues from that summary plus the recent turns kept verbatim, so the next call holds the right facts instead of the whole transcript.
How Bigcircle does it
- Bigcircle recommends starting a single-task agent with a scratchpad file plus compaction and keeping cross-session memory as files a person can open, because a summary that drops one constraint can send the next hundred steps the wrong way.
- Bigcircle keeps recent turns verbatim, compacts older ones once they cross a threshold, and moves durable facts such as a user's stated preferences into agent memory instead of carrying the whole transcript.
- On harness engineering engagements, Bigcircle fixes context assembly and compaction in week 1-3 first, so the window holds what matters instead of an ever-growing transcript.
Comparison
Context compaction shrinks what sits in the live window; agent memory writes durable facts outside the window so a summary does not have to carry them; context editing that only clears old tool results is a lighter form that frees space with less risk of dropping a decision.
Key number
Across 18 models in Chroma's Context Rot tests (Hong, Troynikov and Huber, July 2025), reliability fell as input grew, which is why compaction shrinks the window before asking the model to reason over a long transcript.
Context compaction is how an AI agent frees space in its context window mid-task. It summarizes older turns, keeps the recent ones word for word, and continues from that shorter history. The point is not to cram more text into the window. Keep the facts the next step still needs, and drop the rest before the model starts skipping them.
A bigger window does not remove the need on its own. Across 18 models in Chroma's Context Rot tests (Hong, Troynikov and Huber, July 2025), reliability fell as input grew, even on tasks as simple as finding one sentence. Compaction is the first lever against that, so shrink what the model sees before you ask it to reason over a transcript that has become noise.
The context window page covers the token budget itself, and agent memory covers the notes you write outside the window so a summary does not have to carry every constraint. This page sits between those two as the summarization and pruning step.
What is context compaction?#
Context compaction takes a conversation nearing the window limit, summarizes it, and restarts the next call from that summary plus the recent turns you still want verbatim. Anthropic's Effective context engineering for AI agents, checked 13 November 2026, defines it that way. It treats compaction as the first lever for long-horizon work once the token count exceeds what the window can hold well.
In Claude Code, the history is passed to the model to summarize. Anthropic says the summary should keep architectural decisions, unresolved bugs and implementation details, and drop redundant tool outputs, which are usually most of the tokens. The agent then continues with the compressed context plus the five most recently accessed files. As of November 2026 the Claude API also offers server-side compaction in beta. The API writes a summary of older turns on the server, and you send that block back in place of the messages it covers.
Compaction always loses something on the way. A summary that drops one constraint, such as the Python version a client requires, can send the next hundred steps the wrong way, which is why the practice pairs with a scratchpad. Notes written to files survive the summary word for word, so the summary carries the story and the files carry the facts.
How does context compression free the window?#
People typing "context compression" are usually looking for the same practice under another name: reduce what sits in the window without losing the thread. Full summarization is one form of that, and a lighter form clears old tool results while keeping the messages around them.
Anthropic's context editing docs, checked 13 November 2026, call tool-result clearing one of the safest lightest-touch forms. They treat server-side compaction as the primary strategy for long-running conversations when you want a summary rather than a selective clear. Tool results such as file contents or search hits are often unused after the model has read them. Replacing those results with a short placeholder frees most of the space, with less risk of dropping a decision that lived in the surrounding messages.
Neither form is free of tradeoffs. Compression that maximizes recall on the first pass, then trims what turned out to be noise, is the tuning Anthropic recommends for engineers writing their own compaction prompt. Over-aggressive compression is how a client requirement disappears from the next hundred steps.
What is agent context management?#
Agent context management is the wider job of deciding what enters the window on each turn: the system prompt, the tools, the recent messages, the retrieved notes, and what leaves. Compaction is one lever inside that job, and structured note-taking and splitting work across sub-agents are others Anthropic names in the same essay.
A useful split is working context versus historical context. Working context covers the steps the agent is doing now, kept in full, while historical context covers earlier work, summarized to key facts. Compacting the history while the working set stays intact is how most long tasks stay inside a window the model can still use. Durable facts such as a user's stated preferences belong in agent memory, not in every compacted summary.
The goal is signal rather than volume, because retaining every prior turn in full grows cost linearly and turns older turns into distractors. The context window page already covers why attention favors the edges and why a million-token advertisement is optimistic for reasoning over everything at once. Context management is the runtime policy that acts on that fact before each call.
How Bigcircle does it#
We recommend starting a single-task agent with a scratchpad file plus compaction, and keeping cross-session memory as files a person can open. Current agent frameworks such as Claude Code already ship both, and on the context window page we already state the same shape. Keep recent turns verbatim, compact older ones once they cross a threshold, and move durable facts into agent memory instead of carrying the whole transcript.
We treat deliberate compaction as an active decision about what to keep, what to summarize, and what to drop. Hoping the model will ignore irrelevant content is not a plan. That practice is named on the AI agents roadmap: summarize and prune so the window holds the right facts, not all of them.
Our harness engineering work puts that decision in the runtime. We build context assembly and compaction so the window holds what matters instead of an ever-growing transcript. In week 1-3 of that engagement we fix context and tools first: assembly and compaction, then schema-enforced tool output with a repair path. Those two account for most of the failures that look like the model being unreliable. A summary that drops one constraint still sends the next hundred steps the wrong way, which is why we pair compaction with a scratchpad once the loop runs unattended.
When the transcript is the wrong store#
Skip compaction while a single call still fits and the answer still lands. Add it when history is growing into the space the next answer needs. Add it also when the model starts missing an early constraint that still sits somewhere in the middle of the window.
Do not treat compaction as a substitute for memory either. If a fact has to survive every summary, write it to a file the agent can reopen. If the same workflow comes back tomorrow, that is agent memory, not another pass of summarization. If the window is full of retrieved passages rather than conversation, fix retrieval first. Ten relevant passages still beat a hundred mediocre ones, which is the same trade the context-window page already makes.
Compact when you can name what must stay, what can become a sentence, and what can leave. That decision is the whole practice.