pub struct CompactionConfig {
pub threshold_tokens: usize,
pub retain_recent: usize,
pub min_messages_for_compaction: usize,
pub auto_compact: bool,
}Expand description
Configuration for context compaction.
Controls when and how context compaction occurs.
§Example
use agent_sdk::context::CompactionConfig;
let config = CompactionConfig::default()
.with_threshold_tokens(100_000)
.with_retain_recent(20);Fields§
§threshold_tokens: usizeToken threshold to trigger compaction. When estimated tokens exceed this, compaction is triggered. Default: 80,000 (conservative for 128K context models)
retain_recent: usizeNumber of recent messages to keep intact (not summarized). These messages remain in full to preserve immediate context. Default: 10
min_messages_for_compaction: usizeMinimum messages before compaction is considered. Prevents compaction when conversation is still short. Default: 20
auto_compact: boolWhether to automatically compact when threshold is reached. If false, compaction only occurs on explicit request. Default: true
Implementations§
Source§impl CompactionConfig
impl CompactionConfig
Sourcepub const fn with_threshold_tokens(self, threshold: usize) -> Self
pub const fn with_threshold_tokens(self, threshold: usize) -> Self
Set the token threshold for compaction.
Sourcepub const fn with_retain_recent(self, count: usize) -> Self
pub const fn with_retain_recent(self, count: usize) -> Self
Set the number of recent messages to retain.
Sourcepub const fn with_min_messages(self, count: usize) -> Self
pub const fn with_min_messages(self, count: usize) -> Self
Set the minimum messages for compaction.
Sourcepub const fn with_auto_compact(self, auto: bool) -> Self
pub const fn with_auto_compact(self, auto: bool) -> Self
Set whether to auto-compact.
Trait Implementations§
Source§impl Clone for CompactionConfig
impl Clone for CompactionConfig
Source§fn clone(&self) -> CompactionConfig
fn clone(&self) -> CompactionConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more