---
title: 別の会話にバインドされた思考ブロックを修正する
url: https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/fix-bound-to-a-different-conversation
description: 思考ブロックが別の会話にバインドされていることを示す400エラーの後に会話を再開し、コードが何を変更したかを見つけ、その変更がなくなったことをテストします。
featureMetadata:
  status: stable
  supportedModels:
    - claude-fable-5-2
    - claude-mythos-5-2
    - claude-fable-5-1
    - claude-mythos-5-1
    - claude-opus-5-5
    - claude-sonnet-5-5
    - claude-haiku-5-5
  supportedPlatforms:
    Claude API: stable
    Amazon Bedrock: stable
    Amazon Bedrock (bedrock-runtime): stable
    Claude Platform on AWS: stable
    Claude Models on Google Cloud (Anthropic managed): stable
    Claude Models on Google Cloud (Google managed): stable
    Microsoft Foundry: stable
---

同じリクエストを再送信してもうまくいきません。履歴にはコードが加えた変更がまだ残っているためです。[今すぐエラーを止める](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/fix-bound-to-a-different-conversation#prefix-mismatch-error)には、`"drop_block"`を送信してください。長期的な修正は、コードを[「append-only」（追記のみ）](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/prefix-checks#prefix-check)にすることです。

## エラー: The block is bound to a different conversation

「thinking block」（思考ブロック）が[「prefix check」（プレフィックスチェック）](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/prefix-checks#prefix-check)に失敗しました。Claudeがそのブロックを生成した後に、その前にある何かが変更されたか（[何が変更とみなされるか](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/prefix-checks#what-counts-as-an-edit)を参照）、他の思考ブロックの間にある思考ブロックが省かれたか移動されました。エラーは次のようになり、続けて[何が変更されたかを示す](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/fix-bound-to-a-different-conversation#prefix-mismatch-error-details)場合があります：

```text wrap
messages.1.content.0: 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".
```

「A different conversation」とは、ブロックの前にある内容が異なることを意味します。[プレフィックスチェック](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/prefix-checks#prefix-check)はセッションやユーザーを比較しません。エラーメッセージはブロックを削除するよう指示しますが、[そのブロックだけを削除するのでは不十分です](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/fix-bound-to-a-different-conversation#remove-by-hand)。[他のエラー](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/fix-bound-to-a-different-conversation#similar-errors)も似たように見える場合があります。

アプリが自分のものでない場合は、新しい会話を開始し、そのメンテナーに伝えてください。[シークレット、個人データ、または注入されたテキストを削除した](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/change-tools-or-instructions#remove-sensitive-content)場合、またはリクエストで[思考をオフにしている](https://platform.claude.com/docs/ja/build-with-claude/thinking#turning-thinking-off)場合は、ステップ1の代わりに[思考を手動で削除](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/fix-bound-to-a-different-conversation#remove-by-hand)してください。

<Steps>
  <Step title="今すぐエラーを止める">
    `thinking.block_binding.prefix_mismatch_behavior`を`"drop_block"`に設定し、[ベータヘッダー](https://platform.claude.com/docs/ja/api/beta-headers#beta-features-on-other-platforms) `anthropic-beta: thinking-binding-controls-2026-08-01`を送信します。APIはリクエスト間で設定を保存しないため、会話内の以降のすべてのリクエストでこれを行ってください。保存された会話は、コードを修正した後でも変更を保持したままなので、設定を会話と一緒に保存してください。次のように`type`を`"adaptive"`に設定します：

    ```json
    {
      "thinking": {
        "type": "adaptive",
        "block_binding": {
          "prefix_mismatch_behavior": "drop_block"
        }
      }
    }
    ```

    SDKでは、[テストプログラム](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/fix-bound-to-a-different-conversation#how-to-tell-whether-your-integration-is-impacted-details)のように、ベータ版のMessagesメソッドを呼び出してヘッダー値を渡します。エラーが[まだヘッダーを要求する](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/fix-bound-to-a-different-conversation#setting-not-received)場合、ヘッダーは届いていません。

    これにより無効な思考が除外されてエラーは止まりますが、[コストが増える場合があり](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/fix-bound-to-a-different-conversation#drop-block-cost)、出力の品質とレイテンシに影響する場合があります。次のリクエストは成功し、その`input_transformations`配列には、APIが除外した各ブロックが一覧表示されます。

    リクエストで`thinking`パラメータを設定していない場合、これを追加しても他には何も変わりません。[「preserved thinking」（保持された思考）を備えたモデル](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/prefix-checks#outcomes)は、デフォルトで適応的に思考するためです。
  </Step>

  <Step title="長期的な修正">
    インテグレーションを追記のみにします：

    1. 変更を見つけます。エラーがそれを示す場合があります。コードのどこでその変更を行っているかを見つけるには、`claude update`を実行してから、コードのリポジトリ内のClaude Codeで`/claude-api preserved-thinking-migration`を実行します。または[手動で探します](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/fix-bound-to-a-different-conversation#find-the-change-details)。
    2. その変更をやめてください。そうしないと、新しい会話でもエラーが発生する場合があります。[代わりに末尾で更新を送信します](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/change-tools-or-instructions)。
    3. 実行中の各会話には、[最後に成功したリクエスト](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/change-tools-or-instructions#saved-sessions)の`system`と`tools`を送信し続けてください。
  </Step>
</Steps>

変更が最近のものであれば、代わりに元に戻すこともできます。コードが変更したものを元に戻してください。変更前の思考は再び有効になります。それ以降に生成された思考はプレフィックスチェックに失敗するため、削除するか、`"drop_block"`を送信し続けてください。

## 思考の除外によるコスト

Claudeは、もう読めなくなった推論を改めて導き出すために、より多くの出力トークンを費やす場合があります。また、ブロックを除外すると、最初に除外されたブロック以降のプロンプトキャッシングのキャッシュが無効になります。

毎ターン何かが変更される場合、毎ターン以前のターンの思考が失われるため、増加が繰り返されます。`"drop_block"`に頼る前に、自分のワークロードで評価を実行してください。

<Frame>
  ![変更後の4つのリクエスト：最初のリクエストは拒否され、続く3つは古い思考を除外し、新しいブロックをそれぞれ保持します](https://platform.claude.com/docs/ja/images/preserved-thinking-drop-block-loss.svg)
</Frame>

`"drop_block"`は、修正中の変更を保持している既存の会話を継続させるため、また[独自の要約の後](https://platform.claude.com/docs/ja/build-with-claude/compaction-thinking-blocks#own-summary)など計画的な除外のために使用してください。コードが繰り返し行っている変更を隠すためにこれを有効のままにしないでください。無効なブロックが履歴からなくなったら、[送信をやめる](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/fix-bound-to-a-different-conversation#drop-block-cost-details)ことができます。

## コードが変更したものを見つける

変更は、APIが示す最初のブロックより前にあります。400エラーは、`system`、`tools`、欠落している思考ブロック、または最初に異なるメッセージなど、何が変更されたかを示す場合があります。エラーがない場合や、エラーが変更内容を示さない場合は、`prefix_binding_mismatch`エントリや出力トークンの増加など、[手元にあるものから始めてください](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/fix-bound-to-a-different-conversation#find-the-change-details)。

## コードのプレフィックスチェック失敗をテストする

テストは、それが失敗するのを確認して初めて信頼できます。まず、自分のコードを通じてClaudeに思考させるセッションを実行し、意図的に何かを変更します。このステップでは`"drop_block"`を送信し、最初のブロックで止まるのではなく、レスポンスがすべての無効なブロックを一覧表示するようにします。[5つのステップとプログラム](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/fix-bound-to-a-different-conversation#how-to-tell-whether-your-integration-is-impacted-details)に示すとおりです。

次に、その変更を取り除き、実際のセッションを実行します。すべてのリクエストでベータヘッダー`thinking-binding-controls-2026-08-01`を送信し、[`prefix_mismatch_behavior`](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/prefix-checks#preserved-thinking-controls)を`"error"`に設定します。これにより、それらのセッションでコードが行った変更は、400エラーでビルドを失敗させます。

コンパクションを行う、後からツールを追加する、指示を変更する、[モデルを切り替える](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking#switching-models)、または再開するセッションをテストしてください。通常のターンではそのコードに到達しません。

クリーンな実行とは、`prefix_binding_mismatch`エントリもエラーもない実行です。これが示すのは、実行したセッションにおいて、プレフィックスチェックを受けたブロックが有効であることだけです。次の場合は何も証明しません：

* セッションに思考ブロックがなかった
* コードがすべての思考を取り除いている、またはモデルが保持された思考を備えていない
* ベータヘッダーを送信しておらず、エラーなしで[モデルがプレフィックスチェックに失敗したブロックを通す可能性がある](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/prefix-checks#outcomes)

## 本番環境を監視し、エラーなしで失われた推論を見つける

各400エラーをログに記録し、会話が継続するように[コードで処理](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/fix-bound-to-a-different-conversation#handle-the-error-in-code)してください。代わりに`prefix_mismatch_behavior`を指定しないままにする場合は、Claudeに届いた、プレフィックスチェックに失敗した思考がないか、[本番トラフィックを監視](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/prefix-checks#watch-production-traffic)してください。

推論は、`"drop_block"`、バッチアイテム、モデルの切り替え、[別のアカウント](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking#account-bound-thinking)への移行、または思考を送り返さないコードによって、エラーなしで失われる場合があります。ベータヘッダーがあれば、最後のもの以外はそれぞれエントリを残します。最後のものについては、リクエストに`thinking`ブロックが含まれていることを確認してください。

## 技術的な詳細

### エラーメッセージがほかに示す場合がある内容

APIが判別できる場合、エラーメッセージは続けて、`system`、`tools`、最初に異なるメッセージまたはブロック、欠落している内容や新しい内容、または欠落しているか順序が異なる以前の思考ブロックなど、何が変更されたかを示します。その文の文言は変わる可能性があるため、それに対してマッチングしないでください。リクエストにベータヘッダーがなかった場合、エラーメッセージには次の文が追加されます：

```text wrap
That setting requires the `thinking-binding-controls-2026-08-01` value in the `anthropic-beta` header.
```

### エラーがまだヘッダーを要求する、または`Extra inputs are not permitted`と表示される

エラーがまだヘッダーを要求する場合、ヘッダーはAPIに届いていません。プロキシまたはライブラリがヘッダーを削除した可能性があります。`block_binding: Extra inputs are not permitted`で終わる別のエラーも同じこと、または思考がオフになっていることを意味します。

### 無効な思考を手動で削除する

設定を送信できない場合、または次のいずれかの場合に使用してください：

* シークレット、個人データ、または注入されたテキストを削除した後。`"drop_block"`は保存された履歴に思考を残すためです。
* 思考がオフ（`"disabled"`または`"between_tools"`）の場合。`"drop_block"`には`"adaptive"`が必要で、それにより思考がオンになり、出力トークンが増えるためです。

1. エラーが示すブロックと、その後にあるすべての`thinking`および[`redacted_thinking`](https://platform.claude.com/docs/ja/build-with-claude/thinking#redacted-thinking-blocks)ブロックを削除してください。そうしないと、同じエラーが次の無効なブロックを示します。ただし、履歴に`role: "system"`メッセージ、または同じロールのメッセージが2つ連続して含まれている場合は、すべての`thinking`および`redacted_thinking`ブロックを削除してください。エラーはそのようなメッセージを直前のメッセージの一部として数えるため、エラーが示す位置は配列内のインデックスより小さくなる場合があります。`input_transformations`エントリの`path`は、すべてのメッセージを個別に数えます。
2. 他のすべてのブロックは保持し、リクエストを再送信してください。削除したブロックを元に戻さないでください。

### このエラーに似たエラー

これらのエラーは、ブロックが別の会話にバインドされているとは示しておらず、`prefix_mismatch_behavior`を設定しても解消されない可能性があります：

* 「Invalid `signature` in `thinking` block」の後で終わるメッセージ、「cannot be modified」と示すメッセージ、または`budget_tokens`に関するメッセージ：[思考のトラブルシューティング](https://platform.claude.com/docs/ja/build-with-claude/thinking-troubleshooting)
* `temperature`または事前入力された応答に関するメッセージ：[制限と機能の互換性](https://platform.claude.com/docs/ja/build-with-claude/thinking#limits-and-feature-compatibility)

### `"drop_block"`の送信をやめられるタイミング

`"drop_block"`の送信をやめるには、それが除外するブロックを削除し、それ以降に生成された思考は保持してください。他に何も変更されていなければ、その会話は`"error"`でも通るようになります。

### コードでエラーを処理する

コードでエラーを処理するには、すべてのリクエストでベータヘッダーと`"error"`を送信し、どのモデルでも失敗が400エラーになるようにします。エラーが返されたら、その会話だけを以降のすべてのリクエストで`"drop_block"`に切り替え、その選択を会話と一緒に保存し、一度だけ再送信して、エラーをログに記録します。同じエラーが再び返される場合、設定はAPIに届いていません。[エラーがまだヘッダーを要求する、または`Extra inputs are not permitted`と表示される](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/fix-bound-to-a-different-conversation#setting-not-received)を参照してください。

コードはこのエラーを`message`フィールドで認識する必要があります。これは、エラーのテキストに対してマッチングしないという一般的なアドバイスの例外です。すべての400エラーはタイプ`invalid_request_error`を持ち、このエラーには`error.details.error_code`がありません。メッセージの残りの部分は変わる可能性があるため、「The block is bound to a different conversation」のみでマッチングしてください。

### エラーがない、またはエラーが何が変更されたかを示さない

* **400エラーで、変更が示されていない場合：** リクエストを自分で比較してください。原因の1つは、要約対象のメッセージを削除せずにコンパクションブロックを送信することです。

* **`prefix_binding_mismatch`エントリがある場合：** 最初のエントリの`path`までの`system`、`tools`、`messages`を、そのブロックが生成された時点の会話と比較してください。すべてのブロックが一覧表示されている場合は、`system`と`tools`から始めてください。

  何も違いがない場合は、[内容が変更された画像またはドキュメントのURL](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/change-tools-or-instructions#files-by-id)、MCPサーバーの変更されたツールリスト（[MCPサーバーのツールリストを固定する](https://platform.claude.com/docs/ja/agents-and-tools/mcp-connector#pin-mcp-tool-list)を参照）、または省かれた、移動された、または元に戻された思考ブロックを探してください。リクエストログがない場合は、`"error"`を指定してリクエストを再送信し、何が異なるかを示す文があれば読んでください。

* **自分のものでないプロキシまたはライブラリが間にある場合：** それが送信する内容と、あなたが送信した内容を比較し、そのメンテナーに[ライブラリ、プロキシ、ゲートウェイ](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/change-tools-or-instructions#libraries-proxies-gateways)を案内してください。

* **疑いがあるだけで、Claude Codeがない場合：** 会話のリクエストボディを取得します。コンパクションまたはツール変更を含むものにしてください。新しいターンを除いて、各ボディを直前のものと比較します。

### 失敗し得るテストの5つのステップと、それを実行するプログラム

1. 自分のコードで、[保持された思考を備えたモデル](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/prefix-checks#outcomes)に対し、セッションの各リクエストでベータヘッダーと`"drop_block"`を送信します。
2. Claudeに思考させるプロンプトを使用し、最初のレスポンスに`thinking`ブロックがあることを確認します。適応型思考では、Claudeは簡単なプロンプトでは思考を省略する場合があります。
3. reasonが`prefix_binding_mismatch`である`input_transformations`エントリがある場合にのみ失敗させます。空の配列を期待するテストは、モデルの切り替え後にも失敗します。その場合は`model_binding_mismatch`または`organization_binding_mismatch`のエントリが想定されるためです。
4. 3番目のリクエストでのみ`system`プロンプトを追加するなど、意図的に何かを変更します。
5. `input_transformations`が、変更の後にある思考ブロックを一覧表示していることを確認します。何も一覧表示されない場合は、履歴に思考ブロックが含まれていることを確認してください。

このプログラムはステップ1、2、4、5を実行します。各レスポンスに含まれる思考ブロックと`input_transformations`エントリの数を出力し、続いて各エントリを出力します。これがステップ3でチェックする内容です：

<CodeGroup exclude="shell:cURL, shell:CLI">
  <CodeGroupItem language="cURL">
    このワークフローには、単一のシェルコマンド以上のロジックが必要です。実行するには[Anthropic SDK](https://platform.claude.com/docs/ja/cli-sdks-libraries/overview)を使用してください。
  </CodeGroupItem>

  <CodeGroupItem language="CLI">
    このワークフローには、単一のシェルコマンド以上のロジックが必要です。実行するには[Anthropic SDK](https://platform.claude.com/docs/ja/cli-sdks-libraries/overview)を使用してください。
  </CodeGroupItem>

  ```python Python
  client = anthropic.Anthropic()

  user_turns = [
      "How many positive integers below 500 have exactly 6 positive divisors?",
      "How many have exactly 8?",
      "How many have exactly 10?",
  ]

  messages = []
  for turn, user_turn in enumerate(user_turns, start=1):
      messages.append({"role": "user", "content": user_turn})
      response = client.beta.messages.create(
          model="claude-opus-5-5",
          max_tokens=16000,
          thinking={
              "type": "adaptive",
              "block_binding": {"prefix_mismatch_behavior": "drop_block"},
          },
          # 最後のリクエストだけがシステムプロンプトを追加し、意図的にプレフィックスを変更します
          system="Answer briefly." if turn == len(user_turns) else anthropic.omit,
          messages=messages,
          betas=["thinking-binding-controls-2026-08-01"],
      )
      messages.append({"role": "assistant", "content": response.content})
      thinking_blocks = sum(block.type == "thinking" for block in response.content)
      entries = response.input_transformations or []
      print(f"thinking blocks: {thinking_blocks}, entries: {len(entries)}")
      for entry in entries:
          if entry.type == "thinking_dropped":
              print(entry.type, entry.path, entry.reason)
  ```

  ```typescript TypeScript
  const client = new Anthropic();

  const userTurns = [
    "How many positive integers below 500 have exactly 6 positive divisors?",
    "How many have exactly 8?",
    "How many have exactly 10?"
  ];

  const messages: Anthropic.Beta.BetaMessageParam[] = [];
  for (const [turnIndex, userTurn] of userTurns.entries()) {
    messages.push({ role: "user", content: userTurn });
    const response = await client.beta.messages.create({
      model: "claude-opus-5-5",
      max_tokens: 16000,
      thinking: {
        type: "adaptive",
        block_binding: { prefix_mismatch_behavior: "drop_block" }
      },
      // 最後のリクエストだけがシステムプロンプトを追加し、意図的にプレフィックスを変更します
      system: turnIndex === userTurns.length - 1 ? "Answer briefly." : undefined,
      messages,
      betas: ["thinking-binding-controls-2026-08-01"]
    });
    messages.push({ role: "assistant", content: response.content });
    const thinkingBlocks = response.content.filter((block) => block.type === "thinking");
    const entries = response.input_transformations ?? [];
    console.log(`thinking blocks: ${thinkingBlocks.length}, entries: ${entries.length}`);
    for (const entry of entries) {
      if (entry.type === "thinking_dropped") {
        console.log(entry.type, entry.path, entry.reason);
      }
    }
  }
  ```

  ```csharp C#
  using Anthropic.Models.Beta;
  using Anthropic.Models.Beta.Messages;
  using Model = Anthropic.Models.Messages.Model;

  AnthropicClient client = new();

  string[] userTurns =
  [
      "How many positive integers below 500 have exactly 6 positive divisors?",
      "How many have exactly 8?",
      "How many have exactly 10?",
  ];

  List<BetaMessageParam> messages = [];
  foreach (var (turnIndex, userTurn) in userTurns.Index())
  {
      messages.Add(new BetaUserMessageParam { Content = userTurn });
      var response = await client.Beta.Messages.Create(
          new()
          {
              Model = Model.ClaudeOpus5_5,
              MaxTokens = 16000,
              Thinking = new BetaThinkingConfigAdaptive
              {
                  BlockBinding = new()
                  {
                      PrefixMismatchBehavior = BetaThinkingPrefixMismatchBehavior.DropBlock,
                  },
              },
              // 最後のリクエストだけがシステムプロンプトを追加し、意図的にプレフィックスを変更します
              System = turnIndex == userTurns.Length - 1 ? new("Answer briefly.") : null,
              Messages = messages,
              Betas = [AnthropicBeta.ThinkingBindingControls2026_08_01],
          }
      );
      messages.Add(new BetaAssistantMessageParam
      {
          Content = response.Content.Select(block => new BetaContentBlockParam(block.Json)).ToList(),
      });
      var thinkingBlocks = response.Content.Count(block => block.TryPickThinking(out _));
      var entries = response.InputTransformations ?? [];
      Console.WriteLine($"thinking blocks: {thinkingBlocks}, entries: {entries.Count}");
      foreach (var entry in entries)
      {
          if (entry.TryPickThinkingDropped(out var dropped))
          {
              Console.WriteLine($"{dropped.Type} {dropped.Path} {dropped.Reason.Raw()}");
          }
      }
  }
  ```

  ```go Go
  client := anthropic.NewClient()

  userTurns := []string{
  	"How many positive integers below 500 have exactly 6 positive divisors?",
  	"How many have exactly 8?",
  	"How many have exactly 10?",
  }

  messages := []anthropic.BetaMessageParam{}
  for turnIndex, userTurn := range userTurns {
  	messages = append(messages, anthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock(userTurn)))
  	// 最後のリクエストのみシステムプロンプトを追加し、意図的にプレフィックスを変更します
  	var system []anthropic.BetaTextBlockParam
  	if turnIndex == len(userTurns)-1 {
  		system = []anthropic.BetaTextBlockParam{{Text: "Answer briefly."}}
  	}
  	response, err := client.Beta.Messages.New(context.TODO(), anthropic.BetaMessageNewParams{
  		Model:     anthropic.ModelClaudeOpus5_5,
  		MaxTokens: 16000,
  		Thinking: anthropic.BetaThinkingConfigParamUnion{
  			OfAdaptive: &anthropic.BetaThinkingConfigAdaptiveParam{
  				BlockBinding: anthropic.BetaThinkingBlockBindingParam{
  					PrefixMismatchBehavior: anthropic.BetaThinkingPrefixMismatchBehaviorDropBlock,
  				},
  			},
  		},
  		System:   system,
  		Messages: messages,
  		Betas:    []anthropic.AnthropicBeta{anthropic.AnthropicBetaThinkingBindingControls2026_08_01},
  	})
  	if err != nil {
  		log.Fatal(err)
  	}
  	messages = append(messages, response.ToParam())
  	thinkingBlocks := 0
  	for _, block := range response.Content {
  		if block.Type == "thinking" {
  			thinkingBlocks++
  		}
  	}
  	fmt.Printf("thinking blocks: %d, entries: %d\n", thinkingBlocks, len(response.InputTransformations))
  	for _, entry := range response.InputTransformations {
  		if entry.Type == "thinking_dropped" {
  			fmt.Println(entry.Type, entry.Path, entry.Reason)
  		}
  	}
  }
  ```

  ```java Java
  import com.anthropic.models.beta.AnthropicBeta;
  import com.anthropic.models.beta.messages.BetaContentBlock;
  import com.anthropic.models.beta.messages.BetaInputTransformation;
  import com.anthropic.models.beta.messages.BetaMessage;
  import com.anthropic.models.beta.messages.BetaThinkingBlockBinding;
  import com.anthropic.models.beta.messages.BetaThinkingConfigAdaptive;
  import com.anthropic.models.beta.messages.BetaThinkingPrefixMismatchBehavior;
  import com.anthropic.models.beta.messages.MessageCreateParams;
  import com.anthropic.models.messages.Model;

  void main() {
      AnthropicClient client = AnthropicOkHttpClient.fromEnv();

      List<String> userTurns = List.of(
          "How many positive integers below 500 have exactly 6 positive divisors?",
          "How many have exactly 8?",
          "How many have exactly 10?");

      MessageCreateParams.Builder conversation = MessageCreateParams.builder()
          .model(Model.CLAUDE_OPUS_5_5)
          .maxTokens(16000L)
          .thinking(BetaThinkingConfigAdaptive.builder()
              .blockBinding(BetaThinkingBlockBinding.builder()
                  .prefixMismatchBehavior(BetaThinkingPrefixMismatchBehavior.DROP_BLOCK)
                  .build())
              .build())
          .addBeta(AnthropicBeta.THINKING_BINDING_CONTROLS_2026_08_01);

      for (int turnIndex = 0; turnIndex < userTurns.size(); turnIndex++) {
          if (turnIndex == userTurns.size() - 1) {
              // 最後のリクエストだけがシステムプロンプトを追加し、意図的にプレフィックスを変更します
              conversation.system("Answer briefly.");
          }
          conversation.addUserMessage(userTurns.get(turnIndex));
          BetaMessage response = client.beta().messages().create(conversation.build());
          conversation.addMessage(response);
          long thinkingBlocks = response.content().stream()
              .filter(BetaContentBlock::isThinking)
              .count();
          List<BetaInputTransformation> entries = response.inputTransformations().orElse(List.of());
          IO.println("thinking blocks: " + thinkingBlocks + ", entries: " + entries.size());
          for (BetaInputTransformation entry : entries) {
              entry.thinkingDropped().ifPresent(dropped ->
                  IO.println(entry.type() + " " + dropped.path() + " " + dropped.reason()));
          }
      }
  }
  ```

  ```php PHP
  use Anthropic\Beta\AnthropicBeta;
  use Anthropic\Beta\Messages\BetaThinkingBlock;
  use Anthropic\Beta\Messages\BetaThinkingBlockBinding;
  use Anthropic\Beta\Messages\BetaThinkingConfigAdaptive;
  use Anthropic\Beta\Messages\BetaThinkingDroppedInputTransformation;
  use Anthropic\Beta\Messages\BetaThinkingPrefixMismatchBehavior;
  use Anthropic\Client;
  use Anthropic\Messages\Model;

  $client = new Client();

  $userTurns = [
      'How many positive integers below 500 have exactly 6 positive divisors?',
      'How many have exactly 8?',
      'How many have exactly 10?',
  ];

  $messages = [];
  foreach ($userTurns as $turnIndex => $userTurn) {
      $messages[] = ['role' => 'user', 'content' => $userTurn];
      $response = $client->beta->messages->create(
          model: Model::CLAUDE_OPUS_5_5,
          maxTokens: 16000,
          thinking: BetaThinkingConfigAdaptive::with(
              blockBinding: BetaThinkingBlockBinding::with(
                  prefixMismatchBehavior: BetaThinkingPrefixMismatchBehavior::DROP_BLOCK,
              ),
          ),
          // 最後のリクエストだけがシステムプロンプトを追加し、意図的にプレフィックスを変更します
          system: $turnIndex === array_key_last($userTurns) ? 'Answer briefly.' : null,
          messages: $messages,
          betas: [AnthropicBeta::THINKING_BINDING_CONTROLS_2026_08_01],
      );
      $messages[] = ['role' => 'assistant', 'content' => $response->content];
      $thinkingBlocks = array_filter(
          $response->content,
          fn ($block) => $block instanceof BetaThinkingBlock,
      );
      $entries = $response->inputTransformations ?? [];
      echo 'thinking blocks: ', count($thinkingBlocks), ', entries: ', count($entries), PHP_EOL;
      foreach ($entries as $entry) {
          if ($entry instanceof BetaThinkingDroppedInputTransformation) {
              echo $entry->type, ' ', $entry->path, ' ', $entry->reason, PHP_EOL;
          }
      }
  }
  ```

  ```ruby Ruby
  client = Anthropic::Client.new

  user_turns = [
    "How many positive integers below 500 have exactly 6 positive divisors?",
    "How many have exactly 8?",
    "How many have exactly 10?"
  ]

  messages = []
  user_turns.each_with_index do |user_turn, turn_index|
    messages << { role: "user", content: user_turn }
    # 最後のリクエストだけがシステムプロンプトを追加し、意図的にプレフィックスを変更します
    system_param = (turn_index == user_turns.length - 1) ? { system_: "Answer briefly." } : {}
    response = client.beta.messages.create(
      model: Anthropic::Model::CLAUDE_OPUS_5_5,
      max_tokens: 16_000,
      thinking: {
        type: "adaptive",
        block_binding: { prefix_mismatch_behavior: "drop_block" }
      },
      messages: messages,
      betas: [Anthropic::AnthropicBeta::THINKING_BINDING_CONTROLS_2026_08_01],
      **system_param
    )
    messages << { role: "assistant", content: response.content }
    thinking_blocks = response.content.count { |block| block.is_a?(Anthropic::Beta::BetaThinkingBlock) }
    entries = response.input_transformations || []
    puts "thinking blocks: #{thinking_blocks}, entries: #{entries.length}"
    entries.each do |entry|
      if entry.is_a?(Anthropic::Beta::BetaThinkingDroppedInputTransformation)
        puts "#{entry.type} #{entry.path} #{entry.reason}"
      end
    end
  end
  ```
</CodeGroup>

```text Output wrap
thinking blocks: 1, entries: 0
thinking blocks: 1, entries: 0
thinking blocks: 1, entries: 2
thinking_dropped messages.1.content.0 prefix_binding_mismatch
thinking_dropped messages.3.content.0 prefix_binding_mismatch
```

`"drop_block"`の代わりに`"error"`を使用すると、3番目のリクエストは[400エラー](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/fix-bound-to-a-different-conversation#prefix-mismatch-error)になります。

### 各`input_transformations`エントリの意味と、修正すべきもの

ベータヘッダーを使用すると、思考をサポートするモデルからのレスポンスには、`usage`の横に`input_transformations`配列が含まれます。何も除外されず、無効なものが何も通されなかった場合は空です。「streaming」（ストリーミング）時は、`message_start`イベントの`message`に含まれます。ストリーミング途中のフォールバックの後は、最終的な`message_delta`イベントに含まれるものが正となります。エラーの位置とは異なり、`path`は常に、送信したとおりのブロックの位置です：

```json
{
  "input_transformations": [
    {
      "type": "thinking_dropped",
      "path": "messages.1.content.0",
      "reason": "prefix_binding_mismatch"
    }
  ]
}
```

各エントリの`type`と`reason`、およびその意味：

* **`thinking_dropped`、`prefix_binding_mismatch`：** このブロックの前にあるものが、ブロックが記録したものと一致しません。修正すべきものです：[コードが変更したものを見つける](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/fix-bound-to-a-different-conversation#find-the-change)。
* **`thinking_mismatch_allowed`、`prefix_binding_mismatch`：** 同じですが、Claudeはブロックを変更されないまま読み、課金されます。このエントリは、[一部のモデル](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/prefix-checks#outcomes)で設定が指定されていない場合にのみ表示されます。修正すべきものです。
* **`thinking_dropped`、`model_binding_mismatch`：** このモデルは、ブロックを生成したモデルのブロックを読むことができません。修正すべきものではありません：[会話全体を送信し続けてください](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking#switching-models)。
* **`thinking_dropped`、`organization_binding_mismatch`：** 別のアカウントがブロックを生成したため、[APIがそれを除外しました](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking#account-bound-thinking)。修正すべきものではありません。

認識できない`type`または`reason`を持つエントリは無視してください。

### バッチとトークンカウント

* **[メッセージバッチ](https://platform.claude.com/docs/ja/build-with-claude/batch-processing)：** `prefix_mismatch_behavior`を指定しないアイテムが400エラーを受け取ることはありません。APIは無効なブロックを除外するか、[一部のモデル](https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/prefix-checks#outcomes)ではそれらを通す場合があります。`"error"`を設定したアイテムは、ブロックがプレフィックスチェックに失敗すると`errored`として解決されます。`block_binding`はアイテムの`params.thinking`に入れます。
* **[トークンカウント](https://platform.claude.com/docs/ja/build-with-claude/token-counting)：** Claude APIでは、トークンカウントが同じ400エラーを返す場合があり、同じヘッダーのもとで`prefix_mismatch_behavior`を受け付けます。除外されたブロックはカウントから除かれ、`input_transformations`は返されません。

## 次のステップ

<CardGroup cols={2}>
  <Card title="プレフィックスチェックに失敗せずにツールや指示を変更する" icon="edit" href="https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking/change-tools-or-instructions">
    コードが会話に加える各変更の代わりに送信するもの。
  </Card>

  <Card title="保持された思考" icon="book" href="https://platform.claude.com/docs/ja/build-with-claude/preserved-thinking">
    保持された思考とは何か、思考ブロックが何に紐付けられているか、そしてモデルやアカウントの切り替えについて。
  </Card>

  <Card title="思考のトラブルシューティング" icon="wrench" href="https://platform.claude.com/docs/ja/build-with-claude/thinking-troubleshooting">
    検証できない署名など、その他の思考エラーの修正方法。
  </Card>
</CardGroup>
