pub struct Compactor {
pub threshold: usize,
pub keep_recent: usize,
pub keep_start: usize,
/* private fields */
}Expand description
Compacts conversation history using LLM summarization.
Fields§
§threshold: usizeToken threshold — compact when estimated tokens exceed this.
keep_recent: usizeNumber of recent messages to keep uncompacted.
keep_start: usizeNumber of initial messages to preserve (system + first user).
Implementations§
Source§impl Compactor
impl Compactor
Sourcepub fn with_keep(self, start: usize, recent: usize) -> Self
pub fn with_keep(self, start: usize, recent: usize) -> Self
Create with custom keep parameters.
Sourcepub fn with_prompt(self, prompt: impl Into<String>) -> Self
pub fn with_prompt(self, prompt: impl Into<String>) -> Self
Use a custom compaction prompt instead of the default.
Useful for domain-specific compaction (e.g., sales coaching, code review).
Sourcepub fn needs_compaction(&self, messages: &[Message]) -> bool
pub fn needs_compaction(&self, messages: &[Message]) -> bool
Check if compaction is needed based on estimated token count.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Compactor
impl RefUnwindSafe for Compactor
impl Send for Compactor
impl Sync for Compactor
impl Unpin for Compactor
impl UnsafeUnpin for Compactor
impl UnwindSafe for Compactor
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more