[BUG] /context fails on first try with thinking anabled, works on second try

Resolved 💬 8 comments Opened Oct 1, 2025 by howard1963 Closed Feb 14, 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?

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:

  1. You have extended thinking enabled in your Claude Code settings
  2. When you run /context, Claude Code sends a message to the API
  3. The API response structure requires that when thinking is enabled, the LAST assistant message must start with a <thinking> block before any text or tool use
  4. Claude Code is incorrectly formatting the message - it's sending text first instead of thinking first
  5. 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

  1. enable extended thinking in Claude settings
  2. 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_

View original on GitHub ↗

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