pub struct ContextManagerBuilder { /* private fields */ }Expand description
Configuration for a ContextManager.
Construct via ContextManager::builder. Setters return
Self so calls chain; build is infallible.
Implementations§
Source§impl ContextManagerBuilder
impl ContextManagerBuilder
Sourcepub fn preserve_n_last(self, n: usize) -> Self
pub fn preserve_n_last(self, n: usize) -> Self
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>) -> ContextManagerBuilder
pub fn tokenizer(self, tokenizer: Box<dyn Tokenizer>) -> ContextManagerBuilder
Wire a Tokenizer into the manager. Replaces the default
CharTokenizer fallback so ContextManager::compact_if_needed
measures the budget in real tokens rather than len() / 4.
Sourcepub fn strategy(
self,
strategy: Box<dyn CompactionStrategy>,
) -> ContextManagerBuilder
pub fn strategy( self, strategy: Box<dyn CompactionStrategy>, ) -> ContextManagerBuilder
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.
Sourcepub fn build(self) -> ContextManager
pub fn build(self) -> ContextManager
Finalize the configuration and build the ContextManager.
Infallible — every error case is caught by the typed setters.