Repository navigation
@tanstack/ai-compaction@0.3.0
·
116 commits
to main
since this release
Immutable
release. Only release title and notes can be modified.
Minor Changes
-
#1728
3292bad- Prepare a compaction summary in the background withwithCompaction({ background: { atTokens } }).- When the count at a model call is over
atTokensand not overmaxTokens, the strategy runs on a copy of the messages. The model call does not wait for it. - The result waits in the metadata store (namespace
@tanstack/ai-compaction:background), or in memory without one. It applies at the first model call of the next run: as atanstack.compactionrecord on a durable host, or as the checkpoint. - A model call over
maxTokenswhile the summary runs waits for it and applies it. It compacts inline only when the list is still overmaxTokens. - A result whose kept message is gone, because a newer compaction cut further, is dropped.
compaction:endedandonCompactreport it withstale: true. A failed summary is reported witherrorand applies nothing. CompactionReasonhas a new value,'background'. Setup throws whenatTokensis not belowmaxTokens.
- When the count at a model call is over
-
#1728
3292bad- Count with real usage, compact on demand, and keep compaction in a session log.countTokens: 'usage'counts with the usage the provider reported for the last call, plus an estimate of the newer messages.- When a model call fails with
CONTEXT_OVERFLOW_CODE,withCompactioncompacts and calls the model again in the same run, once per model call. compactNext(threadId)compacts at the next model call.auto: falseturns off compaction atmaxTokensand keepscompactNext, the overflow retry, and the overflow check.durable: truewrites atanstack.compactionrecord throughLogRecordsCapabilitywhen the host provides it. Fold the record into the messages withprojectCompaction.- With
countTokens: 'usage'anddurable: true, a run checks once more after its last model call. When the usage passedmaxTokensorcontextWindow, compaction runs right away.contextWindowalso counts withauto: false. compaction:endedandonCompactreportreason, the summaryusage, and anerror.continueOnErrorsends the full messages when the strategy fails.summarizeOldest({ cut: 'turn' })gives the start of a cut turn its own summary.conversationSummarizerwrites a structured summary, updates the older summary, and takes adetailshook. The summary message is now wrapped in an<untrusted-conversation-summary>tag, so a later compaction can find and update it.
Patch Changes
-
#1787
ee374b4- A failed nativecompactis not saved as the checkpoint or the durable compaction record. The next process callscompactagain. A compact result keeps image files, documents, and audio, and sends those parts back on the next request. -
Updated dependencies [
1d0f8f1,1d0f8f1,5f95dbd,3170517,3292bad,3170517,4298480,f68da51,30fa651,1d0f8f1,3170517,3170517]:- @tanstack/ai@0.70.0