Skip to main content

Module compaction

Module compaction 

Source
Expand description

CompactionStrategy trait and the two built-in implementations. See TruncateStrategy (drop the prefix) and SummarizeStrategy (replace the prefix with a model-generated summary).

Structs§

CompactionOutput
Result of a successful CompactionStrategy::compact call.
SummarizeStrategy
Compaction strategy that calls a CompletionModel to summarize the dropped portion of the history into a single text message, instead of dropping it outright.
TruncateStrategy
Default CompactionStrategy: drop the oldest unpinned messages until the preserved tail starts at a safe User-without- ToolResult boundary. Pinned messages from the dropped prefix survive verbatim at their relative position; the cut never strands a ToolResult from its ToolCall. Reports under CompactionStrategy::name as "truncate".

Constants§

DEFAULT_SUMMARIZER_PROMPT
Default system prompt used by SummarizeStrategy when the caller does not supply one. Kept terse to leave room for the actual transcript inside max_tokens.

Traits§

CompactionStrategy
User-implementable strategy for shrinking a History’s history when History::compact_if_needed runs.