Skip to main content

Module compaction

Module compaction 

Source

Re-exports§

pub use crate::compaction::memory_envelope::effective_context_budget;
pub use crate::compaction::memory_envelope::effective_session_context_budget;
pub use crate::compaction::prefire::AsyncCompactionCache;
pub use crate::compaction::prefire::PrefireState;

Modules§

auto
Unified automatic compaction orchestration.
memory_envelope
Session memory envelope + local compaction helpers, shared by every compaction path (auto, manual /compact, model-switch, recovery, fork).
prefire
two_pass
Pure builders for prefire two-pass compaction.

Structs§

CompactionConfig
Compaction configuration for context window management.
CompactionParentContext
Parent request prefix for cache-safe compaction forking.
CompactionRoutePolicy
Per-route compaction policy in the DeepSeek-harness shape.
ManualCompactionOptions
Universally meaningful manual-compaction options.

Enums§

CompactionStrategy
How the manual /compact command compacts for a given provider/model.

Constants§

SUPPRESS_NONE
SUPPRESS_STICKY
SUPPRESS_TURN
SUPPRESS_UNTIL_SUCCESS

Functions§

bound_compacted_history_to_context
Bound a locally managed compacted history to the resolved context budget, including any caller-supplied session ceiling. Standalone native responses must bypass this helper: their retained items and opaque continuation state are the provider’s canonical next context window.
build_cache_safe_compaction_history
Build a cache-safe compaction history: the parent’s full conversation prefix verbatim, plus the compaction instruction as the only new turn. From the provider’s perspective this looks nearly identical to the parent’s last request, so the cached prefix is reused.
compact_history
Compact conversation history using the configured summarizer.
compact_history_manual
Compact history for the manual /compact command using provider-native compaction when available, falling back to local summarization otherwise.
compact_history_manual_with_budget
Manual compaction with the resolved session context budget applied to native request inputs and locally rebuilt summaries. Native provider responses are returned unchanged so opaque continuation state remains valid.
compact_history_manual_with_parent_context
Manual compaction that reuses the parent segment’s cached prefix.
compact_history_with_budget
Compact conversation history using a caller-resolved context budget for input bounding and locally rebuilt output. Standalone native responses are returned as the provider’s canonical next context window.
compacted_history_shrinks
Whether a compaction result is worth keeping.
manual_compaction_strategy
Select the manual-compaction strategy for a provider/model.