pub struct ContextConfig {Show 19 fields
pub snip_threshold: f64,
pub micro_threshold: f64,
pub collapse_threshold: f64,
pub auto_threshold: f64,
pub renewal_threshold: f64,
pub target_after_compress: f64,
pub snip_per_msg_ratio: f64,
pub carryover_ratio: f64,
pub recovery_content_ratio: f64,
pub preserve_recent_msgs: usize,
pub preserve_recent_turns: usize,
pub render_dashboard: bool,
pub verbose_control_notes: bool,
pub collapse_assistant_narration: bool,
pub micro_compact_idle_minutes: u32,
pub preserved_tool_results: usize,
pub autocompact_buffer: u32,
pub spool_threshold_bytes: u32,
pub spool_preview_bytes: u32,
}Expand description
All compression and context management parameters expressed as fractions of
max_tokens. This is the single control surface for the compression pipeline:
changing max_tokens (e.g. switching model) rescales every derived limit
automatically with no other configuration change required.
Invariant: snip < micro < collapse < auto < renewal (strictly increasing).
Fields§
§snip_threshold: f64§micro_threshold: f64§collapse_threshold: f64§auto_threshold: f64§renewal_threshold: f64§target_after_compress: f64Target rho after any compression pass. Must be < snip_threshold.
snip_per_msg_ratio: f64Fraction of max_tokens any single message may occupy after SnipCompact. Messages smaller than this are never touched.
carryover_ratio: f64Fraction of max_tokens worth of history tokens to carry across renewal. Renewal stops carrying messages once this token budget is exhausted.
recovery_content_ratio: f64Maximum fraction of max_tokens a recovery/replay payload may occupy.
preserve_recent_msgs: usizeRecent history messages always kept during render.
preserve_recent_turns: usizeNumber of most-recent turns (user+assistant pairs) preserved by
CollapseCompactor and AutoCompactor. Each turn = 2 messages, so
the actual message count kept is preserve_recent_turns * 2.
Must be ≥ 1. Default: 2 (= 4 messages).
render_dashboard: boolInclude the dashboard block in the rendered system context. Defaults to false; enable only in explicit agent-os mode.
verbose_control_notes: boolUse verbose internal control notes (e.g. “[SYSTEM] Transaction rollback: …”). Defaults to false; uses concise natural-language notes instead.
collapse_assistant_narration: boolCollapse the narration text of OLD assistant turns (those past the
preserve_recent_msgs window that also carry tool calls) to a short stub at render time —
non-destructively (the full text stays in partitions.history). The model’s user-facing
preamble (“好的,我来…先X”) has no value once it has aged out of the recent window, but
re-feeding it verbatim every turn primes the model to keep emitting the same preamble (an
in-context repetition trap). Tool calls and pairing are untouched; current progress lives in
the TASK STATE turn. Defaults to true.
micro_compact_idle_minutes: u32Minutes of inactivity before triggering Micro-Compact (Layer 3). Defaults to 60 minutes — assumes Prompt Cache has expired by then.
preserved_tool_results: usizeNumber of recent tool results to preserve during Micro-Compact.
autocompact_buffer: u32Buffer size for Auto-Compact trigger (Layer 5). Trigger threshold = max_tokens - autocompact_buffer. Defaults to 13K tokens (p99.99 of summarizer output length + safety margin).
spool_threshold_bytes: u32Byte size above which a single tool result is spooled (Layer 1): the kernel
keeps only a preview in context and emits LargeResultSpooled for the SDK to
persist the full content to disk. Default: 50 KiB. 0 disables spooling.
spool_preview_bytes: u32Preview byte budget kept in context when a tool result is spooled. Default: 2 KiB.
Implementations§
Source§impl ContextConfig
impl ContextConfig
Sourcepub fn target_tokens(&self, max_tokens: u32) -> u32
pub fn target_tokens(&self, max_tokens: u32) -> u32
Token budget to target after a compression pass.
Sourcepub fn snip_per_msg_tokens(&self, max_tokens: u32) -> u32
pub fn snip_per_msg_tokens(&self, max_tokens: u32) -> u32
Per-message token cap used by SnipCompact. Floor of 50 ensures very small context windows still get useful output.
Sourcepub fn carryover_tokens(&self, max_tokens: u32) -> u32
pub fn carryover_tokens(&self, max_tokens: u32) -> u32
Token budget for history carryover across renewal.
Sourcepub fn recovery_content_tokens(&self, max_tokens: u32) -> u32
pub fn recovery_content_tokens(&self, max_tokens: u32) -> u32
Token cap for a single recovery/replay payload.
Sourcepub fn autocompact_threshold(&self, max_tokens: u32) -> u32
pub fn autocompact_threshold(&self, max_tokens: u32) -> u32
Auto-Compact trigger threshold (Layer 5).
Returns max_tokens - autocompact_buffer (absolute value).
Trait Implementations§
Source§impl Clone for ContextConfig
impl Clone for ContextConfig
Source§fn clone(&self) -> ContextConfig
fn clone(&self) -> ContextConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more