Skip to main content

CompactionConfig

Struct CompactionConfig 

Source
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: usize

How 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: AutoCompactTrigger

Which 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

Source

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 known context_window; None when the window or the percentage is unknown. The absolute number is never consulted.
  • Thresholds — None when auto_compact_threshold_tokens is None; otherwise the percentage of a known context_window when 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.

Source

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

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CompactionConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CompactionConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for CompactionConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for CompactionConfig

Source§

impl PartialEq for CompactionConfig

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for CompactionConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for CompactionConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more