Skip to main content
Long conversations outgrow the context window. Compaction is a conditional node that runs once per turn at a clean turn boundary, between input_guard and the agent node. If the whole request (system prompt, running summary, bound tool schemas, and messages) exceeds trigger_pct of the usable input budget, it picks an orphan-safe split point, folds the dropped span into a running summary, and emits RemoveMessage for the dropped ids, shrinking both the in-flight request and the persisted checkpoint. The most recent messages (keep_recent_min) are always kept verbatim. Two strategies ship: hybrid summarizes the dropped span with a clean tool-free summary LLM, trim only drops. The summary rides in the system prompt rather than the message list, so it survives further trimming and --thread resume. The budget math is model-aware: the provider’s live model catalog supplies the context length and max completion tokens, so the trigger, the output reservation, and the max_tokens sent to the LLM all stay honest per model, with a default_context_window fallback on a catalog miss.
This page is in progress. It will cover the compaction_policy.yaml schema in full, the separate tool-output cap (max_tool_message_tokens / max_tool_message_pct, which applies even when compaction is off), and the TUI context meter that reveals as you approach the trigger line.

Architecture

Where the compaction node runs in the turn.

Tools

Why a small core_tools list saves budget.

Providers

Where the context-window numbers come from.