Skip to main content

Module compaction

Module compaction 

Source
Expand description

LLM-based context compaction — summarize old messages to stay within limits.

Unlike simple sliding window (trim_messages), compaction preserves key decisions and file changes by summarizing old messages through a fast LLM.

Structs§

Compactor
Compacts conversation history using LLM summarization.

Enums§

CompactionError
Errors from compaction.

Functions§

estimate_tokens
Estimate token count for messages (rough: chars / 4). Uses char count (not byte length) for correct non-ASCII estimation.