Skip to content

@tanstack/ai-compaction@0.3.0

Choose a tag to compare

@github-actions github-actions released this 19 Oct 16:17
· 116 commits to main since this release
Immutable release. Only release title and notes can be modified.
7095ebb

Minor Changes

  • #1728 3292bad - Prepare a compaction summary in the background with withCompaction({ background: { atTokens } }).

    • When the count at a model call is over atTokens and not over maxTokens, 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 a tanstack.compaction record on a durable host, or as the checkpoint.
    • A model call over maxTokens while the summary runs waits for it and applies it. It compacts inline only when the list is still over maxTokens.
    • A result whose kept message is gone, because a newer compaction cut further, is dropped. compaction:ended and onCompact report it with stale: true. A failed summary is reported with error and applies nothing.
    • CompactionReason has a new value, 'background'. Setup throws when atTokens is not below maxTokens.
  • #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, withCompaction compacts and calls the model again in the same run, once per model call.
    • compactNext(threadId) compacts at the next model call. auto: false turns off compaction at maxTokens and keeps compactNext, the overflow retry, and the overflow check.
    • durable: true writes a tanstack.compaction record through LogRecordsCapability when the host provides it. Fold the record into the messages with projectCompaction.
    • With countTokens: 'usage' and durable: true, a run checks once more after its last model call. When the usage passed maxTokens or contextWindow, compaction runs right away. contextWindow also counts with auto: false.
    • compaction:ended and onCompact report reason, the summary usage, and an error. continueOnError sends the full messages when the strategy fails.
    • summarizeOldest({ cut: 'turn' }) gives the start of a cut turn its own summary. conversationSummarizer writes a structured summary, updates the older summary, and takes a details hook. The summary message is now wrapped in an <untrusted-conversation-summary> tag, so a later compaction can find and update it.

Patch Changes