> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dust.tt/llms.txt
> Use this file to discover all available pages before exploring further.

# Context Compaction

> Summarize the earlier part of a long conversation so the agent keeps the context, and keep working when the context gets full.

Each model can only work with a limited amount of text at once, called its context window. In a long conversation, the context can get full. Context compaction summarizes the earlier part of the conversation, so the agent keeps working with a summary of everything that happened before.

Your messages aren't deleted. Dust adds a compaction marker to the conversation, and the agent uses the summary instead of the older messages.

## When to compact

The context indicator in the message input shows how full the context is, as a percentage. Click it to see the details.

* **From 33%:** you can compact. Click the context indicator, then **Compact now**.
* **From 82%:** a banner shows "Conversation context is almost full," with a **Compact now** button.
* **From 90%:** you must compact before you send a new message. The message input shows "Context is full, compact to continue."

You can only compact a conversation that has at least one finished agent message. You can't compact while an agent works, or compact twice in a row without a new message in between.

## Compact a conversation

**1. Open the context indicator**

In the message input, click the context indicator.

**2. Compact**

Click **Compact now**.

**3. Wait for the summary**

The conversation shows "Compacting context, this may take a moment…". You can't send messages until compaction finishes.

When compaction succeeds, the conversation shows **Context compacted**. If it fails, the conversation shows **Context compaction failed**, and the agent keeps using the full conversation.

## What changes after compaction

After compaction, the agent uses:

* The summary.
* The messages after the compaction marker.

The messages before the marker are still in the conversation, and you can still read them. The agent no longer reads them in full. If you compact again, the agent uses the latest summary.

Dust also saves the full conversation before compaction as a file in the conversation, and tells the agent where it is. When the summary isn't enough, the agent can read this file to find earlier details.

## Limitations

* A model writes the summary, so it can miss details. The agent can still find them in the file of the full conversation.
* Compaction can take up to about a minute for a long conversation.

## Related

> [card] [Understanding LLMs Context Windows](https://docs.dust.tt/docs/user-documentation/agents/llm-best-practices/understanding-llms-context-windows.md)
>
> Learn what a context window is and why it matters.

> [card] [Branch a Conversation](https://docs.dust.tt/docs/user-documentation/agents/branch-a-conversation.md)
>
> Start a new conversation from any point of an existing one.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.