pub enum CompactionTriggerMode {
Threshold,
Overflow,
}Expand description
压缩触发模式 — 决定何时启动自动压缩。
两种模式对应不同的产品哲学:
Threshold: 主动式 — 接近上限时提前压缩,避免 overflow(oh-my-pi, claude-code)Overflow: 被动式 — 仅在实际溢出时才压缩,最大化上下文利用率(opencode)
Variants§
Threshold
达到阈值时主动压缩。
在 token 用量超过阈值(百分比或固定值)时触发, 留出足够空间完成当前对话而不 overflow。 这是 oh-my-pi 和 claude-code 的做法。
Overflow
仅在 context overflow 时被动压缩。
不提前触发,等到 LLM 返回 prompt-too-long 错误时才压缩。 最大化上下文利用率,但用户可能感知到短暂中断。 这是 opencode 的做法。
Trait Implementations§
Source§impl Clone for CompactionTriggerMode
impl Clone for CompactionTriggerMode
Source§fn clone(&self) -> CompactionTriggerMode
fn clone(&self) -> CompactionTriggerMode
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CompactionTriggerMode
impl Debug for CompactionTriggerMode
Source§impl Default for CompactionTriggerMode
impl Default for CompactionTriggerMode
Source§fn default() -> CompactionTriggerMode
fn default() -> CompactionTriggerMode
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for CompactionTriggerMode
impl<'de> Deserialize<'de> for CompactionTriggerMode
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Hash for CompactionTriggerMode
impl Hash for CompactionTriggerMode
Source§impl PartialEq for CompactionTriggerMode
impl PartialEq for CompactionTriggerMode
Source§fn eq(&self, other: &CompactionTriggerMode) -> bool
fn eq(&self, other: &CompactionTriggerMode) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for CompactionTriggerMode
impl Serialize for CompactionTriggerMode
impl Copy for CompactionTriggerMode
impl Eq for CompactionTriggerMode
impl StructuralPartialEq for CompactionTriggerMode
Auto Trait Implementations§
impl Freeze for CompactionTriggerMode
impl RefUnwindSafe for CompactionTriggerMode
impl Send for CompactionTriggerMode
impl Sync for CompactionTriggerMode
impl Unpin for CompactionTriggerMode
impl UnsafeUnpin for CompactionTriggerMode
impl UnwindSafe for CompactionTriggerMode
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
Mutably borrows from an owned value. Read more