Definition: Context compaction is what an AI agent does when a long session fills its context window: it replaces the older part of the transcript with a shorter summary so there is room to keep working, and anything the summary did not mention is gone from the agent's view.
TL;DR: Context compaction rewrites the earlier part of a long AI conversation into a short summary so the agent has room to continue. It is a trade, not a free win. The summary keeps the shape of what happened and drops the specifics, so anything you still need should be saved to a project or agent memory before it gets compacted. Build one free →
You already do this when you hand a long email thread to a colleague. You do not forward all forty messages. You write four lines: here is the client, here is what we agreed, here is what is still open. That is compaction. It is also why your colleague later asks about a detail that was settled in message nine, because your four lines never mentioned it.
Why Context Compaction Matters in 2026
Compaction is the reason a long agent session does not simply stop. The model underneath is stateless, so the entire transcript is re-sent on every request, and every transcript has a ceiling measured in tokens. Without compaction, a session that hits that ceiling either refuses to continue or starts silently dropping its oldest messages, which is worse because nothing tells you. Compaction is also the usual explanation for the thing people find unnerving about agents: one that clearly knew something an hour ago and now does not. The detail was summarized away. Knowing that tells you when to save something rather than assume it will still be there.
How Context Compaction Works
Compaction happens inside the agent harness, not the model. The harness watches how large the assembled request is getting, and when it nears the limit it rewrites its own history before sending the next one. The model is never told. From its side, it receives a shorter conversation that opens with a summary.
- The harness measures. It counts the transcript in tokens, not messages, so one pasted spreadsheet can matter more than fifty short replies.
- It picks a cut line. Recent turns stay exactly as they are, because the current task depends on them. Everything older is a candidate for folding up.
- It asks the model to summarize the older part. This is the lossy step. The model itself decides what was worth keeping, usually decisions made, facts established, and open items.
- It rebuilds the request. The system prompt survives untouched, then the summary, the recent turns, and the tools the agent may call.
- Work resumes. The next pass of the agent loop runs against the rebuilt context, and nothing unusual appears to have happened.
- It can happen again. A very long session may compact several times, producing summaries of summaries that drift further from what was actually said.
Automatic Compaction vs Deliberate Compaction
Auto-compact fires on its own the moment the context gets close to full. You did not ask for it, and in most tools the only sign is a short notice in the transcript. Deliberate compaction is when you choose the moment instead, which is almost always better because you get to pick what survives.
| Automatic (auto-compact) | Deliberate | |
|---|---|---|
| What triggers it | The transcript nears the ceiling | You, at a moment you choose |
| When it lands | Mid-task, whenever the limit arrives | At a clean break between pieces of work |
| What survives | Whatever the model judged important | What you named as important |
| How it feels | The agent keeps going, slightly vaguer | Nothing noticeable, because you set it up |
| Main failure mode | It cuts right before you needed the detail | You forget, and auto-compact fires anyway |
| Better move | Treat the notice as a prompt to save work | Write results to a project, then start fresh |
The habit that follows: when you finish a distinct piece of work, save the outcome somewhere durable and open a new session. That is effectively an agent handoff, where you decide what crosses the boundary instead of letting a summarizer decide for you.
What Compaction Always Loses
Every compaction is a deletion dressed as a summary. Here is one session before and after, so the loss is concrete rather than theoretical.
BEFORE COMPACTION 22 turns, near the context ceiling
turn 3 you pasted the full pricing table, 9 rows, exact numbers
turn 7 an export failed, you said "skip it, we will do it manually"
turn 11 you corrected the client name spelling to "Riverside Ltd"
turn 18 the agent drafted a summary you approved
AFTER COMPACTION 1 summary + turns 19-22 kept word for word
summary "Working on the Q3 renewal for Riverside. Pricing was
discussed. An export failed and was skipped. A draft
summary was approved by the user."
turn 19 ... kept exactly
turn 20 ... kept exactly
That summary is accurate and it is still a serious loss. The nine pricing rows are gone: the agent now knows only that pricing "was discussed". The reason the export was skipped is gone, so it may cheerfully retry it. The spelling correction is gone, so the old spelling returns in the next draft. None of this surfaces as an error. It surfaces as an agent that is quietly less useful than it was twenty minutes ago.
- Anything that must be exact belongs outside the chat. Numbers, names, and agreed wording go into a project or agent memory, not a message you hope survives.
- Corrections are the most fragile thing you say. A summarizer rarely rates "actually, it is spelled Ltd" as important.
- Prefer a fresh session over a heroic long one. Quality falls off well before the ceiling, a pattern known as context rot, so compaction usually arrives after the answers already got worse.
Context Compaction vs Agent Memory
These two get confused constantly, and it is expensive, because people end up relying on compaction to do memory's job. Compaction is damage control inside one run. Agent memory is a deliberate store that outlives every run.
| Trait | Context compaction | Agent memory |
|---|---|---|
| Purpose | Make room to keep working right now | Keep what matters for next time |
| Who decides what is kept | The model, automatically | You, or an explicit rule |
| Lifespan | Dies with the session | Survives into every future session |
| Fidelity | Lossy by design, detail is dropped | Exact, stored as written |
| Where it lives | Inside the context window | Outside the model, retrieved when relevant |
| Cost behaviour | Cuts the cost of a bloated transcript | Flat, only the relevant part is fetched |
Compaction buys you time. Persistent memory buys you continuity. A good agent uses both, and never asks compaction to be the thing that remembers.
Connection to Taskade
Every Taskade AI Agent handles compaction for you, but the more useful part of the design is what makes compaction matter less. Your projects are the durable layer: an agent reads them when a run opens and writes results back before it closes, so the facts that count live in a project rather than a transcript that will eventually be summarized. That is the Memory, Intelligence, and Execution loop of Workspace DNA at work, where Memory is a place you can see.
Inside a run an agent reaches its built-in tools plus the agent knowledge you attach, across 100+ bidirectional integrations so the source of truth stays in the systems your team already uses. The Auto setting routes each step to one of 15+ frontier models from OpenAI, Anthropic, Google, and open-weight providers. When a trigger fires in Taskade Automations, the agent opens a fresh session, which is compaction avoided rather than managed. For how a chat run behaves day to day, see AI Chat in Learn Taskade.
What You Would Build in Taskade
You already lose things this way by hand. A decision gets made in a thread, nobody writes it down, and three weeks later two people remember it differently. Picture a decision log in Taskade. Every time your team settles something, an agent captures it as a structured record: what was decided, who decided it, what it replaces, and the exact numbers or wording involved. It writes that record the moment the decision is made, not at the end of a long conversation when a summarizer is already trimming.
The next run opens against that project and starts with the facts in front of it, so nothing depends on a transcript surviving. Your team reads the same log in whichever of the 7 project views they think in, a list, a table, or a board.
Describe yours and build it free →
Related Concepts
- Context Window: the ceiling compaction exists to respect
- Agent Session: the run that fills up
- Context Rot: why quality drops before the limit is reached
- Agent Memory: what compaction is not a substitute for
- Agent Handoff: choosing what crosses a session boundary
- Token: the unit the ceiling is measured in
- Context Engineering: deciding what the agent sees at all
- Agent Harness: the software that runs compaction
- AI Agents in Taskade: agents that write to projects, not just transcripts
Frequently Asked Questions About Context Compaction
What does auto-compact mean in AI?
Auto-compact means the tool noticed your conversation was about to outgrow its context window and summarized the older part on its own so the session could continue. Nothing broke. Recent turns are kept word for word, older ones become a summary, and any detail that summary skipped is no longer visible to the agent.
Does context compaction delete my conversation?
Not from your screen. You can still scroll back and read everything. It is deleted from what the agent is shown on each new request, which is the part that shapes its answers. That gap between what you see and what the agent sees is why compaction surprises people. Save anything exact to agent memory.
Why did my AI agent forget something I told it?
Usually because it was compacted away. The model is stateless and knows only what is in the current request, so once a detail is folded into a summary that never mentioned it, it is genuinely gone. Corrections and exact figures are the most common casualties.
Is compaction the same as summarizing?
Summarizing is the technique compaction uses, but the purpose differs. A summary you ask for is an output you read. Compaction is a summary the system writes to itself to replace history it can no longer afford to carry, and the agent then treats it as if it were the original conversation.
Should I compact or just start a new session?
Start fresh whenever you finish a distinct piece of work. A new session gives sharper answers than a compacted one, because a summary of twenty turns is always thinner than the twenty turns. Save the outcome into a project first, or carry it forward as an agent handoff.
Do bigger context windows make compaction unnecessary?
No, they move the wall further out. Large windows help, but quality tends to sag long before the limit is reached, a pattern called context rot, and cost rises with every token re-sent. A focused short context usually beats a huge cluttered one, which is why context engineering stays useful however large windows get.
How do Taskade agents avoid losing work in long sessions?
By keeping the durable part outside the session. A Taskade AI Agent reads from your projects when a run opens and writes results back before it closes, so facts live in a project rather than a transcript. Scheduled runs in Taskade Automations start a fresh session each time.
