compactThread
@forge/monorepo / backend/src / compactThread
Function: compactThread()
compactThread(
input):Promise<CompactionResult|null>
Defined in: backend/src/context/compaction.ts:52
Compact a thread's history. Returns null when there is nothing worth compacting (history at or
under keepRecent, or no older messages survive the tool-continuity split). Otherwise summarizes
the older prefix, appends a versioned ThreadSummary, and reports what was reclaimed.
Parameters
input
conversationId
estimateTokens
(messages) => number
Token estimate for a set of messages, used to report tokensReclaimed.
keepRecent
number
How many trailing messages to keep verbatim.
messages
readonly Message[]
Full history, oldest first.
summaries
summarizer
tenantId
Returns
Promise<CompactionResult | null>