pub struct CompactionConfig {
pub trigger: CompactionTrigger,
pub strategy: CompactionStrategy,
pub min_recent_turns: usize,
}Expand description
Compaction configuration: trigger + strategy + safety floor.
Fields§
§trigger: CompactionTriggerWhen to compact.
strategy: CompactionStrategyHow to compact.
min_recent_turns: usizeSafety floor: never drop below this many recent steps, even if the trigger and strategy would remove more. Prevents pathological configs from wiping the whole history.
Implementations§
Source§impl CompactionConfig
impl CompactionConfig
Sourcepub fn new(trigger: CompactionTrigger, strategy: CompactionStrategy) -> Self
pub fn new(trigger: CompactionTrigger, strategy: CompactionStrategy) -> Self
Creates a config from trigger + strategy (default floor of 2).
Sourcepub fn with_min_recent_turns(self, min_recent_turns: usize) -> Self
pub fn with_min_recent_turns(self, min_recent_turns: usize) -> Self
Sets the safety floor (never keep fewer than this many steps).
Sourcepub fn compact(
&self,
steps: &[AgentStep],
tokens: usize,
) -> (Vec<AgentStep>, usize)
pub fn compact( &self, steps: &[AgentStep], tokens: usize, ) -> (Vec<AgentStep>, usize)
Returns the retained steps and how many were dropped.
Pure: (kept, dropped) with kept.len() + dropped == steps.len() and
kept a suffix of steps (order and pairing preserved — no orphaned
actions). A no-op returns (the same steps, 0) when the trigger does
not fire or the floor is already reached.
Trait Implementations§
Source§impl Clone for CompactionConfig
impl Clone for CompactionConfig
Source§fn clone(&self) -> CompactionConfig
fn clone(&self) -> CompactionConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CompactionConfig
impl RefUnwindSafe for CompactionConfig
impl Send for CompactionConfig
impl Sync for CompactionConfig
impl Unpin for CompactionConfig
impl UnsafeUnpin for CompactionConfig
impl UnwindSafe for CompactionConfig
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