claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] API Error 400: Invalid 'text' content - Expected 'thinking' block

Open backnotprop opened this issue 1 year ago • 14 comments

This happens sometimes on random prompts in TUI. Since the latest 0.2.120 update.

I say random because sometimes I have thinking trigger words in the prompts, sometimes I don't. In both cases I will get this error:

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"me
    ssages.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 (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.anthropic.com/en/docs/build-with-claude/extended-thinking"}}

Usually I can just resend the prompt and it works. Thinking still works in this case as well.

Same issue as AI slop bugs: #1174 #1167

backnotprop avatar May 19 '25 21:05 backnotprop

Running /login fixed it: https://github.com/anthropics/claude-code/issues/1167#issuecomment-2891409005

Edit: as others are pointing out, this doesn't actually fix it. Just a coincidence I happened to stop pressing escape after running /login.

beala avatar May 19 '25 23:05 beala

Running /login fixed it: #1167 (comment) was about to say I have the same issue and occurs when interjecting claude using esc . I will try this but would be good to know what the cause was. thanks!

btebbutt96 avatar May 19 '25 23:05 btebbutt96

/login has not fixed it for me.

Again seeing: (this wasn't a thinking-triggered prompt)

 API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"me
    ssages.123.content.0: When thinking is disabled, an `assistant` message in the final
     position cannot contain `thinking`. To use thinking blocks, enable `thinking` in
    your request."}}

backnotprop avatar May 20 '25 01:05 backnotprop

I see this consistently after I hit esc to interrupt

:: claude -v 
0.2.122 (Claude Code)

junoatwork avatar May 20 '25 03:05 junoatwork

@junoatwork yea

I see this consistently after I hit esc to interrupt

same - consistent pattern identified.

backnotprop avatar May 20 '25 04:05 backnotprop

Having the same issue, typically after saying 'no' and then giving my new instructions, but it could also be after i hit esc.

jriskin avatar May 20 '25 05:05 jriskin

This is now basically every command after I hit esc and reprompt with clarification.

Super annoying

backnotprop avatar May 20 '25 19:05 backnotprop

This is now basically every command after I hit esc and reprompt with clarification.

Super annoying

the login comment above doesn't fix this .

Can reproduce the bug every single time by clicking esc .

Are you an api user or max plan? wondering / sincerely hope it's not something affecting max plan users only.

btebbutt96 avatar May 20 '25 23:05 btebbutt96

i have this error with max plan, didnt hit escape, only hit No, then typed my changes i wanted, then it appears. not always though!

nsanden avatar May 21 '25 18:05 nsanden

We think this should be fixed in the latest version. Please update and reopen this ticket if you run into it again!

reverie avatar May 21 '25 18:05 reverie

We think this should be fixed in the latest version. Please update and reopen this ticket if you run into it again!

Still running into this on the latest version. Happens frequently if I hit 'esc' during some active thinking/processing.

If I quit, and claude --continue it will still be broken also. I have to start a new session.

mmcdole avatar Jun 11 '25 22:06 mmcdole

Haven't seen this error since closed FYI.

nsanden avatar Jun 12 '25 11:06 nsanden

Have

  ⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.15.content.1: When 
    providing `thinking` or `redacted_thinking` blocks, the blocks must match the parameters during the original 
    request."}}

every time using thinking mode after 60-120 seconds after initial promt. WSL, VS Code, Win11

Kanezal avatar Jun 13 '25 00:06 Kanezal

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.

github-actions[bot] avatar Aug 10 '25 14:08 github-actions[bot]