[BUG] API 400 error: assistant message thinking blocks serialized with `text` before `thinking` in conversation replay

Resolved 💬 7 comments Opened Jan 25, 2026 by SixteenLetters Closed Jan 26, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When using Claude Code with claude-opus-4-5-20251101 in auto thinking mode, every tool-use turn triggers an API 400 error on the subsequent API round-trip. The error states that an assistant message has a text block before a thinking block, violating the API's ordering constraint.

The error is 100% reproducible — in a single session, it triggered on every single tool call (8 out of 8), across 4 different tool types (AskUserQuestion, Chrome MCP computer, Read, Edit, Bash). Claude Code retries and recovers, so the session continues, but every tool-use turn costs an extra failed API call.

The 8th occurrence returned a more detailed error message revealing the likely root cause:

"When thinking is enabled, a final assistant message must start with a thinking block (preceding the lastmost set of tool_use and tool_result blocks). We recommend you include thinking blocks from previous turns. To avoid this requirement, disable thinking."

This suggests Claude Code may be stripping or not preserving thinking blocks from previous assistant turns when replaying conversation history, causing the API to reject the request.

What Should Happen?

All assistant messages with thinking blocks should have thinking or redacted_thinking as the first content block when replayed in conversation history. Tool-use turns should not trigger API validation errors.

Error Messages/Logs

Primary error (occurred 7 times):**

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.N.content.0: If an assistant message contains any thinking blocks, the first block must be `thinking` or `redacted_thinking`. Found `text`."}}


**Expanded error (occurred on 8th trigger, more detailed):**

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.37.content.0.type: Expected `thinking` or `redacted_thinking`, but found `text`. When `thinking` is enabled, a final `assistant` message must start with a thinking block (preceeding the lastmost set of `tool_use` and `tool_result` blocks). We recommend you include thinking blocks from previous turns. To avoid this requirement, disable `thinking`. Please consult our documentation at https://docs.claude.com/en/docs/build-with-claude/extended-thinking"}}


**All 8 occurrences from a single session:**

| # | Error location | Tool that preceded it | Request ID |
|---|---------------|----------------------|------------|
| 1 | `messages.3.content.0` | Unknown (previous session) | `req_011CXTEZ3PEWeQsDVw8pGWb9` |
| 2 | `messages.9.content.0` | `AskUserQuestion` | `req_011CXTExGAZz1e5brbP1Ec6q` |
| 3 | `messages.13.content.0` | `AskUserQuestion` | `req_011CXTF5YW2gANXrUcNdFzxE` |
| 4 | `messages.21.content.0` | Chrome MCP `computer` | `req_011CXTFG74PKdAVcqdmZ28C3` |
| 5 | `messages.25.content.0` | Chrome MCP `computer` + `Read` | `req_011CXTFJyv75yutKTwuRwDT9` |
| 6 | `messages.29.content.0` | `Edit` | `req_011CXTFP6733tYW8VSkU5Lbr` |
| 7 | `messages.33.content.0` | `Edit` | `req_011CXTFVdKuyKn84ZSTjYNXo` |
| 8 | `messages.37.content.0` | `Edit` + `Bash` (parallel) | `req_011CXTFYcxRNr1X8VMT4CMc3` |

Message index progression: 3 → 9 → 13 → 21 → 25 → 29 → 33 → 37 (always `.content.0`)

Steps to Reproduce

Start a Claude Code session with claude-opus-4-5-20251101 (thinking mode: auto)

  1. Send a message that triggers thinking (e.g., a question that requires reasoning)
  2. Send a follow-up message that triggers a tool call (e.g., "read file X", or use any tool)
  3. After the tool result is returned, the next API call to replay conversation history fails with the 400 error
  4. Claude Code retries and succeeds, but the error occurs every time

The key conditions appear to be:

  • Auto thinking mode (some turns have thinking blocks, some don't)
  • Multi-turn conversation with tool use
  • Conversation history replay after tool results

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.19 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

The error is non-fatal — Claude Code retries and the session continues. But it adds latency and wastes an API call on every tool-use turn.

  • The 8th error's expanded message ("We recommend you include thinking blocks from previous turns") strongly suggests the client is not preserving thinking blocks when serializing conversation history.
  • The error was observed across multiple tool types: built-in (AskUserQuestion, Read, Edit, Bash) and MCP-based (Chrome browser automation computer tool). This rules out any tool-specific cause.
  • The message index always points to .content.0, meaning the first content block in the flagged assistant message is text when it should be thinking.
  • Multiple MCP servers were connected during the session (Asana, Gmail, Google Drive, Claude in Chrome), but the error is tool-type-agnostic.

View original on GitHub ↗

This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗