Skip to main content

Module compactor

Module compactor 

Source
Expand description

Five-stage progressive compaction (DESIGN.md §9), borrowed from Claude Code.

DefaultCompactor is purely structural — it doesn’t call a model. Stage 3 (Microcompact) and Stage 5 (AutoCompact) would normally invoke a cheap LLM; here we collapse content into terse summaries so the framework can run offline. Wire a ModelBackedCompactor later if you want semantic summaries.

Structs§

DefaultCompactor
Heuristic compactor — operates on the structure of the context only.
ModelBackedCompactor
Compactor that calls an LLM for the inferential stages and falls back to DefaultCompactor’s structural strategies for the computational ones.

Constants§

CALIBRATION_KEY
Context::metadata key under which the loop stores a calibration factor — the ratio of the model’s real reported input_tokens to this compactor’s char-based estimate on the previous turn. budget() multiplies its raw estimate by it, so the trigger auto-aligns to the actual model + language (a fixed tokens_per_char badly under-counts CJK, over-counts nothing).