Skip to main content

Module compaction

Module compaction 

Source

Functionsยง

archive
Append the pre-compaction history to the archive on disk.
compact
Compact the message history via an LLM-generated summary.
compact_split
Hierarchical compaction used when primary compact() fails.
count_tokens
Count tokens in a single string using cl100k_base.
estimate_tokens
Count total tokens across all messages.
should_compact
Returns true if compaction should fire. Fires when estimate_tokens(messages) + tool_overhead_tokens >= compact_at_tokens.