[BUG] /context fails on first try with thinking anabled, works on second try
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?
Here is the error being returned: Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.373.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"},"request_id":"req_011CTgunMYhfTRB5CtNiStG4"}
I asked Claude Code (Sonnet 4.5 1M) about this and this is what is said:
This is not a connection error - it's a bug in how Claude Code handles the /context command with extended thinking enabled.
The Issue
The error message is very clear:
messages.373.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
What's happening:
- You have extended thinking enabled in your Claude Code settings
- When you run /context, Claude Code sends a message to the API
- The API response structure requires that when thinking is enabled, the LAST assistant message must start with a
block before any text or tool use - Claude Code is incorrectly formatting the message - it's sending text first instead of thinking first
- The retry works because the second attempt might be structured differently in the conversation history
Solutions
Option 1: Disable extended thinking (quick fix)
In Claude Code settings, turn off extended thinking
Option 2: Report the bug (proper fix) This is a bug in Claude Code itself. You should report it at: https://github.com/anthropics/claude-code/issues
Option 3: Workaround (what you're already doing) Just retry the /context command when it fails - the second attempt usually works because the conversation state is slightly different.
Why It Works on Retry
On the first /context attempt, your last message was my response (text without thinking block). On the second attempt, there's now an error message in the history, which changes how Claude Code constructs the next API call, and it happens to format it correctly.
Bottom line: This is a Claude Code bug, not a you problem or a connection issue. The retry workaround is fine for now, but reporting it would help get it fixed properly.
What Should Happen?
when calling /context, Claude should handle the thinking state in such a way as not to throw an error when calling /context
Error Messages/Logs
Steps to Reproduce
- enable extended thinking in Claude settings
- Call /context using Sonnet 4.5
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
Sonnet 4.2
Claude Code Version
2.0.2 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
No response
same error here.
first time:
/context ⎿ Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.109.content.0.type: Expected
thinkingorredacted_thinking, but foundtext. Whenthinkingis enabled, a finalassistantmessage must start with a thinking block (preceeding the lastmost set oftool_useandtool_resultblocks). We recommend you include thinking blocks from previous turns. To avoid this requirement, disablethinking. Please consult our documentation at https://docs.claude.com/en/docs/build-with-claude/extended-thinking"},"request_id":"req_011CUtVPxfeUMqhHtFrYGsUS"}
2nd time: "request_id":"req_011CUtix6MfZSXhdhtac6uVp"}
Same here, happened multiple times now.
Mine was a duplicate of this issue if this helps: Session was running since yesterday. everything else looks the same from above. I did use ultrathink in the same session earlier but not sure if its related.
Environment Info Platform: darwin Terminal: ghostty Version: 2.0.36 Feedback ID: ea3e39f6-b62a-4c17-b97a-193a7ef2f91e
Same for me but on 2.0.53
Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.101.content.0.type: Expected `thinking` or `redacted_thinking`, but found `tool_use`. 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"},"request_id":"req_011CVUPubkppCemPk65TAQMT"}
Switch model, solution in comments https://github.com/anthropics/claude-code/issues/13669
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.