Skip to content

Context compression ​

Keep long conversations inside the model's context window. Automatic trimming runs every turn at no cost; compaction (/compact) summarises the conversation and only runs when you ask.

A topic transcript with a Context compacted divider, the older messages dimmed above it, and the conversation stats panel showing the context window bar and a Compact context buttonA topic transcript with a Context compacted divider, the older messages dimmed above it, and the conversation stats panel showing the context window bar and a Compact context button
After /compact, the older messages stay visible but dimmed; the model works from the summary.

Automatic trimming ​

Applied to what the model sees, never to the transcript:

  • Inline images in tool results (e.g. base64 Playwright screenshots, ~150,000 characters each) become placeholders like [binary omitted: ~138 KB].
  • Tool results over 2,000 characters older than the last 5 user turns are sent as a short preview; the model can call the tool again. Set the number of turns in Settings → Model → Prompt budgeting → Keep tool results in full for the last N turns (llm_tool_result_keep_turns; 0 = always full).

Max tokens per tool result and Max input tokens per request still apply afterwards; past the budget, the oldest turns are dropped without a summary.

Compacting a topic or chat ​

Run /compact [focus] or click Compact context in the conversation stats panel. The model writes a summary (goal, key facts and decisions with names/IDs/numbers/URLs verbatim, work done, open questions, current state) saved as a compaction marker. From the next turn the model sees the summary plus later messages.

  • /compact keep the SKU comparison and the pricing figures steers it.
  • Older messages stay visible, dimmed. Show summary on the marker shows what the model works from.
  • Undo on the marker restores the full history.
  • Compacting again folds the previous summary in.
  • Not available while a reply is generating.
  • Uses the conversation's model; tokens count under /compact in Settings → Usage stats.

Knowing when to compact ​

The stats panel's context window bar splits the last turn's usage:

SegmentContains
System promptRole, instructions, skills, memories
System toolsBuilt-in tools (the precursor server, the approval tool)
MCP toolsOther enabled MCP servers' tool definitions; often the largest. Disable servers you don't need.
MessagesThe conversation, tool results included
Free space / BufferWhat's left; the buffer is the last 20% of the window
The conversation stats panel with a segmented context window bar and a legend listing system prompt, system tools, MCP tools, messages, free space and buffer with their share and token countThe conversation stats panel with a segmented context window bar and a legend listing system prompt, system tools, MCP tools, messages, free space and buffer with their share and token count
The context window, broken down by what fills it.

Values marked ≈ are Precursor's estimates (providers report one total); a linked issue's body isn't counted. Past 80%, Compact context turns amber (also on the collapsed rail).

The conversation stats panel with the context window bar at 87% and an amber call-out: Context is 87% full, with a Compact context buttonThe conversation stats panel with the context window bar at 87% and an amber call-out: Context is 87% full, with a Compact context button
Past 80% of the window, the stats panel suggests compacting.

After a compaction, until the next turn, Next turn (estimate) shows the history to be sent, what trimming saved, and how many messages the marker covers (system prompt and tools excluded).

Agents show the same bar in the Insights panel, from the Copilot SDK's split, with a single System tools row.

The agent Insights panel with the same segmented context window bar and legendThe agent Insights panel with the same segmented context window bar and legend
The agent Insights panel, with the SDK's own breakdown.

Compacting an agent ​

The Copilot SDK compacts agent history on its own when the window runs low. To compact now, run /compact [focus] in the agent's composer or click Compact context under Usage in the insights sidebar, while the agent is at rest. Every compaction shows as a context compacted marker in the timeline with tokens before/after; hover it for the summary.

See also ​

Released under the MIT License.