Expand description
Compaction planning + assembly (M2).
Pure functions: the engine owns the trigger and the summarize call; this
module decides what folds and assembles the new projection. The shape is
always preserved prefix + typed digest + verbatim tail, and the tail
snaps to a clean boundary so tool_use/tool_result pairing survives
(split-turn handling): a tail may start at a User or an Assistant item,
never at ToolResults (results must follow their assistant message).
Structs§
Constants§
Functions§
- apply
- The new projection: preserved prefix + digest + verbatim tail.
- digest_
item - The digest as a provenance-tagged user item.
- floor_
digest - The degradation floor: every summarize attempt failed, so the session continues with an honest placeholder instead of bricking.
- plan
- Choose what to fold. Picks the earliest clean boundary whose tail fits
tail_budgettokens (keeping the most verbatim history that fits); if no tail fits, keeps the minimal clean tail and folds everything else.Nonemeans nothing can fold — the caller must surface context exhaustion rather than loop. - summarize_
prompt - Render the folded items as a plain transcript for the summarize call. Tool results are clipped per-item — the digest needs their gist, and the summarize call must stay far smaller than the window being compacted.