claude-code - 💡(How to fix) Fix [BUG] API Error 400: thinking block missing in multi-turn conversations with extended thinking enabled [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#51985Fetched 2026-04-23 07:39:37
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
1
Participants
Timeline (top)
labeled ×4

Error Message

When using Claude Code CLI in a multi-turn conversation with extended thinking enabled, after several exchanges the following error appears and the session becomes unusable: API Error: 400 messages.1.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 (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.

Error Messages/Logs

  1. After several exchanges, the error appears and repeats on every message

Fix Action

Fix / Workaround

The only workaround is to disable extended thinking entirely, which degrades response quality.

RAW_BUFFERClick to expand / collapse

Preflight Checklist

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

What's Wrong?

When using Claude Code CLI in a multi-turn conversation with extended thinking enabled, after several exchanges the following error appears and the session becomes unusable:

API Error: 400 messages.1.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 (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.

The only workaround is to disable extended thinking entirely, which degrades response quality.

What Should Happen?

Claude Code should preserve the thinking blocks in the conversation history when making subsequent API calls, so that multi-turn conversations with extended thinking enabled work without errors across all exchanges.

Error Messages/Logs

Steps to Reproduce

  1. Start a Claude Code CLI session with extended thinking enabled (default)
  2. Have a multi-turn conversation with several tool uses (file reads, edits, etc.)
  3. After several exchanges, the error appears and repeats on every message

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.117

Platform

AWS Bedrock

Operating System

Other Linux

Terminal/Shell

Other

Additional Information

OS: Arch Linux with Hyprland (wayland compositor) Terminal: kitty Shell: bash

extent analysis

TL;DR

Preserve thinking blocks in the conversation history to fix the API Error 400 when using Claude Code CLI with extended thinking enabled.

Guidance

  • Verify that the issue is indeed caused by the missing thinking blocks in the conversation history by checking the API request payload.
  • Modify the Claude Code CLI to include thinking blocks from previous turns in the conversation history.
  • Test the fix by having a multi-turn conversation with several tool uses and checking if the error appears.
  • If the issue persists, try disabling extended thinking to confirm that it's the root cause.

Example

No code snippet is provided as the issue does not contain sufficient information about the code.

Notes

The issue seems to be a regression, and the previous version that worked is not specified. The fix may require changes to the Claude Code CLI to preserve the thinking blocks in the conversation history.

Recommendation

Apply workaround: Modify the Claude Code CLI to preserve thinking blocks in the conversation history, as disabling extended thinking degrades response quality and is not a suitable long-term solution.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING