data/compact/compaction_service library
Classes
- CompactionResult
- Result of a compaction operation.
- CompactionService
- Context compaction service.
- CompactProgressEvent
- Progress event emitted during compaction.
- RecompactionInfo
- Diagnosis context for recompaction tracking.
Enums
- CompactHookType
- Hook type for progress reporting.
- CompactionStrategy
- Strategy that triggered the compaction.
- CompactProgressType
- Progress event types emitted during compaction.
- PartialCompactDirection
- Direction for partial compaction around a selected message.
Constants
- autocompactBufferTokens → const int
- Buffer tokens subtracted from context window for auto-compact threshold.
- clearedMessage → const String
- Cleared content replacement marker.
-
compactableToolNames
→ const Set<
String> - Tools whose results can be safely cleared during microcompaction.
- compactMaxOutputTokens → const int
- Max output tokens for summary generation.
- errorIncompleteResponse → const String
- Error when streaming was interrupted mid-compact.
- errorNotEnoughMessages → const String
- Error when there are not enough messages to compact.
- errorPromptTooLong → const String
- Error when the conversation is too long even for compact.
- errorUserAbort → const String
- Error when the user aborts the compact request.
- imageMaxTokenSize → const int
- Flat token estimate for images.
- maxCompactStreamingRetries → const int
- Max streaming retries for compact API calls.
- maxConsecutiveFailures → const int
- Max consecutive compact failures before circuit breaker trips.
- maxPtlRetries → const int
- Max prompt-too-long retries before giving up.
- postCompactMaxFilesToRestore → const int
- Max files to re-inject after compaction for context continuity.
- postCompactMaxTokensPerFile → const int
- Max tokens per individual file in post-compact restore.
- postCompactMaxTokensPerSkill → const int
- Max tokens per skill in post-compact restore.
- postCompactSkillsTokenBudget → const int
- Total token budget for all skills in post-compact restore.
- postCompactTokenBudget → const int
- Token budget for post-compact file attachments.
- ptlRetryMarker → const String
- Prompt-too-long retry marker prepended to truncated messages.
Functions
-
buildPostCompactMessages(
CompactionResult result) → List< Message> - Build the ordered post-compact messages from a CompactionResult.
-
mergeHookInstructions(
String? userInstructions, String? hookInstructions) → String? - Merge user-supplied custom instructions with hook-provided instructions.
-
stripImagesFromMessages(
List< Message> messages) → List<Message> - Strip image and document blocks from user messages before compaction.
-
stripReinjectedAttachments(
List< Message> messages) → List<Message> - Strip attachment types that are re-injected post-compaction anyway.
Typedefs
- OnCompactProgress = void Function(CompactProgressEvent event)
- Callback signature for compaction progress events.
Exceptions / Errors
- CompactionException
- Exception thrown when compaction fails.