Skip to main content

Module compaction

Module compaction 

Source
Expand description

Context compaction for long sessions.

This module ports the pi-mono compaction algorithm:

  • Estimate context usage and choose a cut point that keeps recent context
  • Summarize the discarded portion with the LLM (iteratively updating prior summaries)
  • Record a compaction session entry containing the summary and cut point
  • When building provider context, the session inserts the summary before the kept region and omits older messages.

Structs§

CompactionDetails
Details stored in CompactionEntry.details for cumulative file tracking.
CompactionPreparation
CompactionResult
FileOperations
ResolvedCompactionSettings

Functions§

compact
compaction_details_to_value
prepare_compaction
summarize_entries