Skip to content

ModelCompactor

reference
1 min readUpdated

Kind: Class

Source: atloria-monorepo/libs/agent-core/src/context/model-compactor.ts

Methods

MethodSignatureReturns
compactcompact(items: unknown[])Promise<string>
getSummarygetSummary()`CompactionSummary
setSummarysetSummary(summary: CompactionSummary)void
getEventsgetEvents()readonly CompactionEvent[]
formatSummaryForContextformatSummaryForContext()string
hasPendingCompactionhasPendingCompaction()boolean
flushflush()Promise<void>
resetreset()void

Where it refuses work

  • ModelCompactor stops the work with Error when !content — “Compaction model returned empty content”.
  • ModelCompactor stops the work with Error when !parsed.sessionGoal && typeof parsed.sessionGoal !== 'string' — “Invalid compaction summary: missing sessionGoal”.
  • ModelCompactor stops the work with Error when !parsed.progress || typeof parsed.progress !== 'object' — “Invalid compaction summary: missing progress”.
  • ModelCompactor stops the work with an early return when historyText.length < 100.
  • ModelCompactor stops the work with an early return when !this.currentSummary.
  • ModelCompactor stops the work with an early return when this.config.useV1Endpoint.

When something fails

  • ModelCompactor handles failure in 1 place: it logs it and continues in all 1.

Was this page helpful?

Download as PDF