ai-anthropic: 400 on signed thinking blocks after compaction rewrites history (missing block_binding drop_block)

オープン
#1,959 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@tombeckenham がすでに取り組んでいます。

2026年10月31日 から。

評価

この issue はまだ評価されていません。

説明

waiting-on: maintainer
What happens

With @tanstack/ai-anthropic 1.0.0, @tanstack/ai-harness 0.1.1 and withCompaction (summarizeOldest), the first model call after a compaction fails with a 400 from Anthropic (Claude Sonnet 5.5, reasoning: 'medium'):

messages.1.content.1: Invalid `signature` in `thinking` block. The block is bound to a different conversation. Remove the block, or set `thinking.block_binding.prefix_mismatch_behavior` to "drop_block". That setting requires the `thinking-binding-controls-2026-08-01` value in ...

Compaction replaces the earlier messages with a summary, so the signed thinking blocks of the kept turns no longer match the conversation prefix they were bound to.

Expected

The adapter sends thinking.block_binding: { prefix_mismatch_behavior: "drop_block" } with the thinking-binding-controls-2026-08-01 beta whenever thinking is on (pi-ai does this), or drops thinking blocks before the rewritten prefix itself.

Workaround

A custom fetch on anthropicText(model, { fetch, midConversationChannels: true }) that adds the field and the beta header. With it, the same 5-question run with compaction completes. (Passing fetch turns midConversationChannels off, so it has to be set back on.)

Where

packages/ai-anthropic/src/text/reasoning.ts builds thinking without block_binding; checked on main at 3ce3085.

主要言語
TypeScript
スター
3.3k
フォーク
378
平均マージ
1日 1分
マージ済み PR(30日)
208

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

TanStack/ai のほかの issue

TanStack/ai の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。