#[non_exhaustive]pub enum CompactionStrategy {
SlidingWindow {
keep_recent_turns: usize,
},
TokenBudget {
max_tokens: usize,
keep_recent_turns: usize,
},
ClearToolUses {
keep_recent_turns: usize,
placeholder: String,
},
}Expand description
How to compact. All strategies drop the oldest turns and keep at least
CompactionConfig::min_recent_turns recent ones.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
SlidingWindow
Keep only the most recent keep_recent_turns steps (sliding window).
TokenBudget
Drop the oldest steps until the estimated token footprint is within
max_tokens, but never below keep_recent_turns steps.
Fields
ClearToolUses
ClearToolUses (C2, v0.22.1 §S8): trim context without dropping turns.
Replaces the tool observation text of steps older than the most recent
keep_recent_turns with a short placeholder. Every step is retained —
history length is preserved and no action is orphaned from its
(placeholder) observation, so the model still sees the full k-ary
sequence of tool calls, just without the bulky results. Idempotent:
already-clear observations are left untouched on later compactions.
Trait Implementations§
Source§impl Clone for CompactionStrategy
impl Clone for CompactionStrategy
Source§fn clone(&self) -> CompactionStrategy
fn clone(&self) -> CompactionStrategy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more