pub struct Config {
pub compaction_interval: i32,
pub overlap_size: i32,
pub token_threshold: i32,
pub event_retention_size: i32,
pub summarizer: Option<Arc<dyn Summarizer>>,
}Expand description
Configures context compaction for an application.
At least one strategy must be enabled; a Config that enables neither is rejected by
Config::validate. Use None (Option<Config>) to disable compaction.
- Sliding window (
compaction_interval,overlap_size) runs after an invocation completes and summarizes whole invocations at a time. - Tail retention (
token_threshold,event_retention_size) runs inside an invocation before a model call and summarizes everything but the most recent events once the prompt grows past a token budget.
Both can be enabled at once and they compose, but the sliding window consumes the events tail
retention would otherwise summarize: tail retention only fires when more events accumulate
between windows than event_retention_size holds back.
Fields§
§compaction_interval: i32Number of new user-initiated invocations that triggers a sliding-window compaction; also the most invocations one compaction covers. Zero disables sliding-window compaction.
overlap_size: i32How many already-compacted invocations to pull back into the next sliding window, for
continuity between summaries. Only meaningful alongside compaction_interval.
token_threshold: i32Prompt token count at which tail-retention compaction fires before a model call. Zero disables tail-retention compaction. Summaries produced by this strategy do not pass through the plugin pipeline.
event_retention_size: i32How many of the most recent events are kept raw when tail retention fires. Required with
token_threshold.
summarizer: Option<Arc<dyn Summarizer>>Produces the summary content. When None, the runner supplies an LlmSummarizer backed by
the root agent’s model, which therefore has to be an LLM agent.