pub struct CompactionPolicy {
pub trigger_threshold: f32,
pub max_tool_result_chars: usize,
pub preserved_turns: usize,
pub trim_turn_threshold: usize,
pub collapse_turn_threshold: usize,
pub circuit_breaker_threshold: usize,
pub output_reserve: u32,
}Expand description
Configurable compaction policy documenting threshold math and limit sources.
All thresholds have documented defaults and source precedence. This struct makes the compaction decision boundary explicit and testable (MEM-005-A).
Fields§
§trigger_threshold: f32Fraction of model_limit that triggers compaction (default: 0.8).
max_tool_result_chars: usizeMaximum characters per tool result before budget truncation (default: 4000).
preserved_turns: usizeNumber of recent turns preserved verbatim, never compacted by layers 4/5 (default: 10).
trim_turn_threshold: usizeTurn threshold for trim layer — tool results older than this are emptied (default: 20).
collapse_turn_threshold: usizeTurn threshold for collapse layer — turns older than this are summarized (default: 10).
circuit_breaker_threshold: usizeMaximum consecutive failures before circuit breaker trips (default: 3).
output_reserve: u32Tokens reserved for model output, reducing effective context budget (placeholder, default: 0).
Implementations§
Source§impl CompactionPolicy
impl CompactionPolicy
Sourcepub fn trigger_tokens(&self, model_limit: u32) -> u32
pub fn trigger_tokens(&self, model_limit: u32) -> u32
Returns the token threshold at which compaction triggers.
Source precedence: model_limit * trigger_threshold - output_reserve.
Trait Implementations§
Source§impl Clone for CompactionPolicy
impl Clone for CompactionPolicy
Source§fn clone(&self) -> CompactionPolicy
fn clone(&self) -> CompactionPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more