Skip to content
BENIBIX Learn

Context Compaction

AI💬 LLMsLLM Basics

Also known as Conversation Compaction, Context Summarization

Summing up a long chat so it fits in the window again.

Think of it like

It is like packing for a trip. You fold a big pile of clothes into one small bag.

Example

In Claude Code, typing /compact swaps the chat so far for a short summary. The task goes on with lots of free space.

Why it matters

Long agent tasks fill the window fast. Compaction lets them keep going without starting over.

Definition

Context compaction is shrinking a long chat so it fits back in the model's context window. When the window is nearly full, the app asks the model to sum up what has happened so far. The summary takes the place of the old messages, and the chat goes on from there. Key facts, choices and open tasks stay, while long tool outputs and side talk are dropped. Some details are always lost, so key rules belong in a file the app loads again.
A full window of old turns becomes one short summary, with room to keep working.

Common mistake

Expecting every detail to stay. A summary drops things, so write key rules in a file.

Key takeaways

  1. 1
    Sum up the past. Old turns become one note.
  2. 2
    Free space. Room for new work.
  3. 3
    Some loss. Details can drop out.

Learn it properly