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

# Compaction

> Automatic conversation compaction keeps each request inside the model's context window without losing the thread.

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.

<Note>
  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.
</Note>

<Columns cols={3}>
  <Card title="Architecture" icon="layers" href="/concepts/architecture">
    Where the compaction node runs in the turn.
  </Card>

  <Card title="Tools" icon="wrench" href="/concepts/tools">
    Why a small `core_tools` list saves budget.
  </Card>

  <Card title="Providers" icon="cpu" href="/guides/providers">
    Where the context-window numbers come from.
  </Card>
</Columns>
