CompactionManager class final

The compaction pipeline over a Session, mirroring pi's harness-level compact().

Usage mirrors pi: callers check shouldCompact with estimateContextTokens against the model's context window, then call compactSession explicitly (pi compacts on demand while the harness is idle, never inside the run loop).

Constructors

CompactionManager({required SummarizeFn summarize, CompactionSettings settings = defaultCompactionSettings, CompactionPrompts prompts = defaultCompactionPrompts, Future<void> memoryExtractionHook(String summarizedText)?, int? summarizerWindow, PinnedOperativePayload? pinnedOperative})
Creates a CompactionManager with an injected summary LLM call.
const

Properties

hashCode → int
The hash code for this object.
no setterinherited
memoryExtractionHook → Future<void> Function(String summarizedText)?
Optional Phase 2 hook: called after a successful compaction with the summarized span's text, so durable facts can be extracted into the long-term memory store. Failures are swallowed (never block compaction).
final
pinnedOperative → PinnedOperativePayload?
gh-1409: the session's compaction-pinned skill operative lines. null (default) → every prompt is byte-identical to the pre-pin pipeline (F4 compat guard).
final
prompts → CompactionPrompts
The summarization prompts (built-in unless overridden via the CLI config prompts: section).
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
settings → CompactionSettings
Thresholds and retention settings for compactSession.
final
summarize → SummarizeFn
The summary LLM call used for every summarization.
final
summarizerWindow → int?
The summarizer model's own context window (issue #729) — the smol role's when it differs from the main model's. null leaves the summarization payloads unbounded (legacy behavior); when set, every outbound summary request is chunked/truncated to summarizationPayloadBudget so it fits the summarizer's window.
final

Methods

compact(CompactionPreparation preparation, {String? customInstructions, CancelToken? cancelToken}) → Future<CompactionResult>
Generate compaction summary data from a preparation.
compactSession(Session session, {String? customInstructions, CancelToken? cancelToken}) → Future<CompactionRecord?>
Compact the active branch of session and append a CompactionRecord.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
prepareCompaction(List<SessionRecord> pathEntries, {required int tokensBefore, CompactionSettings? settings}) → CompactionPreparation?
Prepare session branch records for compaction, or return null when compaction is not applicable (empty branch, or the last entry is already a compaction).
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited