pub struct CompactionConfig {
pub max_truncation_recoveries: u8,
pub auto_enabled: bool,
pub auto_threshold_percent: u8,
pub tail_turns: usize,
pub tail_token_budget: usize,
pub tool_output_max_chars: usize,
pub summary_max_tokens: usize,
pub summarizer_input_token_budget: usize,
pub min_response_reserve_tokens: usize,
pub max_response_reserve_tokens: usize,
}Expand description
Context-compaction settings.
Every field maps onto a crate::domain::CompactionPolicy knob that was
previously a hard-coded constant. Values are sanitized on the way out (see
CompactionConfig::policy) rather than validated on the way in: a bad
number should degrade to the nearest sane one, not refuse to start the app.
Fields§
§max_truncation_recoveries: u8Cap on consecutive auto-compact-and-continue recoveries after a
context-window truncation, before the run stops and shows the manual
levers (/context max, /context offload on). The counter resets
whenever the run makes progress, so this bounds only no-progress
thrashing on a too-small window. 0 means uncapped.
Example:
[compaction]
max_truncation_recoveries = 0 # never give up on its ownauto_enabled: boolCompact automatically when the context crosses the threshold below.
false leaves compaction entirely to /compact — the provider’s own
context limit then becomes the only backstop.
auto_threshold_percent: u8Window fill (percent) at which auto-compaction triggers. Clamped to
1..=100; a value of 100 effectively means “only when the response
reserve no longer fits”.
tail_turns: usizeHow many trailing user turns survive compaction verbatim. Clamped to at least 1 — a compaction that preserved no turn would hand the model a summary with no live thread to continue.
tail_token_budget: usizeToken ceiling on that preserved tail. When the last tail_turns exceed
it, older turns are dropped from the tail until it fits.
tool_output_max_chars: usizePer-message character cap applied to tool output inside the summarizer’s history excerpt (prose gets 4x this). Keeps one enormous tool result from crowding out the rest of the conversation.
summary_max_tokens: usizeCeiling on the checkpoint the summarizer may produce. Scaled DOWN
automatically for small context windows (see
CompactionPolicy::summary_output_tokens), so this is a cap and not a
demand.
summarizer_input_token_budget: usizeCeiling on the summarizer’s input (prompt scaffold plus history excerpt). Also scaled down to fit a small window.
min_response_reserve_tokens: usizeFloor and ceiling on the window room held back for the model’s reply when deciding whether the context counts as “full”. Swapped values are corrected rather than rejected.
max_response_reserve_tokens: usizeImplementations§
Source§impl CompactionConfig
impl CompactionConfig
Sourcepub fn policy(&self) -> CompactionPolicy
pub fn policy(&self) -> CompactionPolicy
The live policy, with every value clamped into a range compaction can actually operate in.
Sanitizing here rather than at load time means a hand-edited config can
never put the app in a state where compaction silently cannot run — the
failure mode that motivated it is a min_response_reserve above
max_response_reserve, which would make response_reserve return the
smaller maximum and quietly under-reserve on every turn.
Trait Implementations§
Source§impl Clone for CompactionConfig
impl Clone for CompactionConfig
Source§fn clone(&self) -> CompactionConfig
fn clone(&self) -> CompactionConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CompactionConfig
impl Debug for CompactionConfig
Source§impl Default for CompactionConfig
impl Default for CompactionConfig
Source§impl<'de> Deserialize<'de> for CompactionConfigwhere
CompactionConfig: Default,
impl<'de> Deserialize<'de> for CompactionConfigwhere
CompactionConfig: Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more