Expand description
Compaction (RFC 0026 §5.2): when a context’s token estimate crosses
context.compact_at × model_window (or context.compact is called), the
older messages are summarized by a structured think into the summary
block, the last keep_last messages stay verbatim, the plan stays
verbatim, skill bodies not referenced in the kept window are evicted (the
names stay), the version bumps and the record is checkpointed.
The runtime never calls the model itself, so compaction is two halves: a
pure plan (plan_compaction — which messages to fold + the prompt +
the output schema for the summarizer) and a pure apply
(apply_compaction — fold the summarizer’s verdict into the context).
The turn worker runs the think in between.
Structs§
- Compaction
Outcome - Compaction
Request - A prepared compaction: what to summarize and how.
Functions§
- apply_
compaction - Fold the summarizer’s verdict into the context: absorb the summary, drop
the folded messages, bump the version, evict unreferenced skill bodies
(names stay — the caller drops the bodies from its cache), recount.
Refuses when the context changed since the plan (
versiondrift). - apply_
fallback - A degraded compaction for when the summarizer is unavailable: fold the older messages into a plain narrative built from their rendered lines (truncated). Never loses the plan or the skill names.
- plan_
compaction - Decide what to fold.
keep_lastmessages stay verbatim; a fold always ends before the kept window and never splits an assistant tool-call from its tool results. ReturnsNonewhen there is nothing worth folding (fewer thankeep_last + 2messages). - summary_
schema - The summarizer’s output schema (RFC 0026 §5.1 summary block).