feat(ai-anthropic): support native on-demand compaction
Maintainer thường phản hồi trong vòng 1 ngày
@tombeckenham đang làm issue này rồi.
Từ ngày 7/11/2026.
Đánh giá
Issue này chưa được đánh giá.
Mô tả
Request
Implement explicit, on-demand native compaction in @tanstack/ai-anthropic, exposed through the existing optional TextAdapter.compact() capability and consumed by withCompaction({ native: adapter }).
Current behavior
Checked @tanstack/ai-anthropic 1.1.1 and current main. The Anthropic text adapter has no compact() implementation. Passing it as native therefore uses the configured strategy. createAnthropicSummarize is ordinary chat-based summarization, not Anthropic's native compaction operation.
The existing abstraction appears suitable: #1729 added provider-native compaction, with an OpenAI Responses implementation and strategy fallback. I found no existing issue or PR requesting the Anthropic equivalent.
Why this is useful
Claude applications using TanStack's compaction middleware currently need their own provider bridge to call native compaction. That duplicates provider request mapping, capability checks, cancellation, error handling, and usage parsing. Keeping those responsibilities in the adapter would make this capability reusable across applications while retaining the existing portable strategy fallback and full-transcript/provider-context split.
This is an additional provider strategy, not a claim that native summaries are lossless or always preferable to application-defined summaries.
Provider requirements and interface gap
Anthropic documents on-demand compaction as a separate Messages request with compaction: { type: "summarize" } and the compact-2026-09-04 beta. Models expose support through capabilities.compaction.
Unlike the initial OpenAI implementation, it needs the conversation's system prompt and tool definitions, plus an explicit output allowance. TextCompactOptions currently carries system prompts but neither tools nor model options. A supported way to provide the relevant chat configuration would be needed rather than silently dropping tools or asking applications to rebuild provider serialization.
Other important behavior:
- Propagate cancellation and
wrapFetch. - Keep the compaction call outside ordinary tool execution.
- Validate
stop_reason === "compaction"and a nonempty compaction block. HTTP 200 can otherwise contain no usable summary. - Preserve provider data in the returned result, including the signature.
- Let unsupported models or unusable results enter the existing strategy fallback.
- Account for compaction usage, which Anthropic reports in
usage.iterations.
Scope
This request concerns explicit native compaction through the existing adapter/middleware model. Provider-managed threshold compaction, new persistence infrastructure, and a general signed-block replay or retained-thinking redesign are outside this request. The detailed replay contract can be discussed separately, while ensuring the native result is not reduced to unsigned text.
#1959 and #2040 address signed thinking blocks after history rewriting. They do not implement the native compaction operation requested here.
Is extending TextCompactOptions with the required chat configuration the preferred direction, or would maintainers prefer adapter-specific compaction options?
- Ngôn ngữ chính
- TypeScript
- Star
- 3.3k
- Fork
- 378
- Merge trung bình
- 1 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 253
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của TanStack/ai
-
openai-base: a Responses max_output_tokens cutoff ends as RUN_ERROR without usage instead of finishReason 'length'Có thể đã có người làm @tombeckenham đã nhận 9 ngày trước. Đang mởhas-pr waiting-on: maintainer
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
TanStack/ai#1916 · 1 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
@tanstack/openai-base: strict structured output skips $defs/definitions, so recursive zod schemas are rejectedCó thể đã có người làm @jherr đã nhận hôm nay. Đang mởhas-pr waiting-on: maintainer
TanStack/ai#2076 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Approval resume validates null-widened history args, so approved tools fail with repairToolInput: falseCó thể đã có người làm @tombeckenham đã nhận hôm nay. Đang mởwaiting-on: maintainer
TanStack/ai#2073 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
ai-sandbox: encrypt snapshot blobs at rest with an encrypting blob store wrapperCó thể đã có người làm @AlemTuzlak đã nhận 1 ngày trước. Đang mởwaiting-on: maintainer
TanStack/ai#2062 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Sandbox takeover: the saved transcript loses everything the first host delivered before the restartCó thể đã có người làm @tombeckenham đã nhận 1 ngày trước. Đang mởwaiting-on: maintainer
TanStack/ai#2061 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
binding:python bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
coollabsio/orbit#72 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
Maintainer thường phản hồi trong vòng 1 ngày
-
bug needs-triage potential-regression
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
aws/aws-sdk-js-v3#8408 ·
Maintainer thường phản hồi trong vòng 1 ngày