pub struct HistoryBuilder { /* private fields */ }Expand description
Configuration for a History.
Construct via History::builder. Setters return
Self so calls chain; build is infallible.
Implementations§
Source§impl HistoryBuilder
impl HistoryBuilder
Sourcepub fn preserve_n_last(self, n: usize) -> HistoryBuilder
pub fn preserve_n_last(self, n: usize) -> HistoryBuilder
Number of trailing messages the strategy must preserve verbatim
(after walking back to a safe User-without-ToolResult
boundary). Default: 4. Lowering it lets compaction reclaim more
budget at the cost of dropping more recent context; raising it
keeps recent turns at the cost of compacting sooner.
Sourcepub fn tokenizer(self, tokenizer: Box<dyn Tokenizer>) -> HistoryBuilder
pub fn tokenizer(self, tokenizer: Box<dyn Tokenizer>) -> HistoryBuilder
Wire a Tokenizer into the manager. Replaces the default
CharTokenizer fallback so History::compact_if_needed
measures the budget in real tokens rather than len() / 4.
Sourcepub fn strategy(self, strategy: Box<dyn CompactionStrategy>) -> HistoryBuilder
pub fn strategy(self, strategy: Box<dyn CompactionStrategy>) -> HistoryBuilder
Wire a CompactionStrategy into the manager. Replaces the
default TruncateStrategy. Use
Box::new(SummarizeStrategy::new(model)) to compress dropped
history into a model-generated summary instead of losing it.