Skip to content

CompactionManager

Defined in: agent/compaction/manager.ts:63

CompactionManager orchestrates context compaction for an agent.

It:

  • Monitors token usage before each LLM call
  • Triggers compaction when threshold is exceeded
  • Coordinates with ConversationManager to update history
  • Tracks statistics for observability

new CompactionManager(client, model, config): CompactionManager

Defined in: agent/compaction/manager.ts:75

LLMist

string

CompactionConfig = {}

CompactionManager

checkAndCompact(conversation, iteration): Promise<CompactionEvent | null>

Defined in: agent/compaction/manager.ts:95

Check if compaction is needed and perform it if so.

IConversationManager

The conversation manager to compact

number

Current agent iteration (for event metadata)

Promise<CompactionEvent | null>

CompactionEvent if compaction was performed, null otherwise


compact(conversation, iteration, precomputed?): Promise<CompactionEvent | null>

Defined in: agent/compaction/manager.ts:152

Force compaction regardless of threshold.

IConversationManager

The conversation manager to compact

number

Current agent iteration (for event metadata). Use -1 for manual compaction.

PrecomputedTokens

Optional pre-computed token counts (passed from checkAndCompact for efficiency)

Promise<CompactionEvent | null>

CompactionEvent with compaction details


getStats(): CompactionStats

Defined in: agent/compaction/manager.ts:226

Get compaction statistics.

CompactionStats


isEnabled(): boolean

Defined in: agent/compaction/manager.ts:242

Check if compaction is enabled.

boolean