pub struct CompactionConfig {
pub keep_recent_tool_results: usize,
pub projected_tool_result_budget: Option<ProjectedToolResultBudget>,
pub auto_compact_trigger: AutoCompactTrigger,
pub auto_compact_threshold_tokens: Option<usize>,
pub auto_compact_threshold_percent: Option<u8>,
pub transcript_dir: PathBuf,
pub summary_max_input_chars: usize,
pub summary_max_output_tokens: u32,
pub mode: CompactionMode,
pub preserve_recent_user_tokens: usize,
pub preserve_recent_delegation_results: usize,
pub max_persisted_transcripts: Option<usize>,
}Expand description
Controls request-only tool-result projection and canonical summary compaction.
These mechanisms are separate. Request-only elision changes a cloned main model request and does not further change the persisted transcript. Summary compaction replaces canonical transcript items and persists the result.
Fields§
§keep_recent_tool_results: usizeHow many of the most recent tool results remain unchanged when the history is rebuilt for a provider request.
Every older result larger than 100 bytes is replaced by a
[Previous: used <tool>] marker. When
projected_tool_result_budget is None, that rewrite runs before every
main model request, at any context size, and the projected history is
also what the auto-compaction threshold measures. Each changed request emits
AgentEvent::RequestToolResultsElided.
This is a count heuristic, not a request-size bound: the newest results
can be arbitrarily large, old results of at most 100 bytes survive, and
non-tool content is unaffected. usize::MAX disables the rewrite and is
the default. Lower it only for a workload whose old tool results are
genuinely disposable.
projected_tool_result_budget: Option<ProjectedToolResultBudget>Optional strict aggregate budget for projected tool-result bodies.
When set, this policy is used exclusively and
keep_recent_tool_results is not consulted. None preserves the exact
legacy recent-count behavior. Auto-compaction measures this same
budget-shaped main-request projection. Budgeting adds no retrieval
mechanism; tool-result paging remains an independent, live-agent-only
feature.
auto_compact_trigger: AutoCompactTriggerWhich signal decides that a run auto-compacts. See
AutoCompactTrigger; the default reproduces the pre-0.24 resolution
of the two numbers below exactly, including None tokens meaning off.
auto_compact_threshold_tokens: Option<usize>The token count above which a run compacts, when the model’s context window is unknown.
Under the default AutoCompactTrigger::Thresholds, None here
disables auto-compaction outright, whatever the window is — this field
is both the fallback and the off switch, which is why
AutoCompactTrigger exists. Under
AutoCompactTrigger::WindowShareOnly this field is not consulted at
all, and under AutoCompactTrigger::Off neither is anything else.
auto_compact_threshold_percent: Option<u8>The percentage of the model’s context window to compact at, when the window is known.
A single absolute token count is the one model-dependent constant that
cannot be model-independent: 50k is most of a 64k window and a rounding
error in a 1M one, so a fixed number either compacts a large model far
too eagerly or leaves a small one to overflow. When
ModelInfo::context_window is
known, this percentage of it wins; otherwise
auto_compact_threshold_tokens does. None here always uses the
absolute number — or, under
AutoCompactTrigger::WindowShareOnly, means off. Values above 100
are treated as 100.
transcript_dir: PathBuf§summary_max_input_chars: usize§summary_max_output_tokens: u32§mode: CompactionMode§preserve_recent_user_tokens: usize§preserve_recent_delegation_results: usize§max_persisted_transcripts: Option<usize>Implementations§
Source§impl CompactionConfig
impl CompactionConfig
Sourcepub fn auto_compact_threshold(
&self,
context_window: Option<usize>,
) -> Option<usize>
pub fn auto_compact_threshold( &self, context_window: Option<usize>, ) -> Option<usize>
Resolves the token count at which a run compacts, for a model whose
context window is context_window. None means this run does not
auto-compact.
Every outcome, by auto_compact_trigger:
Off—None, always.WindowShareOnly— the percentage of a knowncontext_window;Nonewhen the window or the percentage is unknown. The absolute number is never consulted.Thresholds—Nonewhenauto_compact_threshold_tokensisNone; otherwise the percentage of a knowncontext_windowwhen both are set, and that absolute number in every remaining case.
A percentage above 100 is treated as 100, so the threshold can never exceed the window it is a share of.
Sourcepub fn auto_compact_enabled(&self) -> bool
pub fn auto_compact_enabled(&self) -> bool
Whether auto-compaction can fire at all, for some context window.
The off state is otherwise only observable by resolving the threshold
against a window and finding None, which a host cannot do
window-independently without reimplementing
auto_compact_threshold. true does
not promise this run compacts: under
AutoCompactTrigger::WindowShareOnly a model with no declared
context window still never reaches a threshold.
Trait Implementations§
Source§impl Clone for CompactionConfig
impl Clone for CompactionConfig
Source§impl Debug for CompactionConfig
impl Debug for CompactionConfig
Source§impl Default for CompactionConfig
impl Default for CompactionConfig
Source§impl<'de> Deserialize<'de> for CompactionConfig
impl<'de> Deserialize<'de> for CompactionConfig
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>,
impl Eq for CompactionConfig
Source§impl PartialEq for CompactionConfig
impl PartialEq for CompactionConfig
Source§impl Serialize for CompactionConfig
impl Serialize for CompactionConfig
impl StructuralPartialEq for CompactionConfig
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.