Skip to content

[Bug] Anthropic API Error: Assistant message thinking block must be first #20725

Closed as not planned

Description

@abose

Bug Description
I cant use claude code in linux or mac, all getting error-ed out with API Error (I'm on the MAX plan):

 400 {"type":"error","error":{"type":"invalid_request_error","message":"m
    essages.5.content.0: If an assistant message contains any thinking blocks, the     
    first block must be `thinking` or `redacted_thinking`. Found                       
    `text`."},"request_id":"req_011CXTPxYCGvoJZ711qbqL1F"}  

If i disable thinking from config, it works. It looks like an account elevl issue as i have it in both my Linux and mac machines.

Environment Info

  • Platform: linux
  • Terminal: pycharm
  • Version: 2.1.19
  • Feedback ID: 3bfa7a6e-69c3-4628-b9f3-c1c2dcfba112

Errors

[{"error":"Error: ENOENT: no such file or directory, scandir '/etc/claude-code/.claude/skills'\n    at readdirSync (unknown)\n    at <anonymous> (/$bunfs/root/claude:12:1903)\n    at pJ (/$bunfs/root/claude:11:35427)\n    at readdirSync (/$bunfs/root/claude:12:1864)\n    at XY$ (/$bunfs/root/claude:2213:380)\n    at XY$ (/$bunfs/root/claude:2213:1350)\n    at <anonymous> (/$bunfs/root/claude:2213:4440)\n    at <anonymous> (/$bunfs/root/claude:2213:5171)\n    at A (/$bunfs/root/claude:11:7251)\n    at Z71 (/$bunfs/root/claude:4860:4342)","timestamp":"2026-01-25T03:28:06.698Z"},{"error":"Error: ENOENT: no such file or directory, scandir '/home/home/.claude/skills'\n    at readdirSync (unknown)\n    at <anonymous> (/$bunfs/root/claude:12:1903)\n    at pJ (/$bunfs/root/claude:11:35427)\n    at readdirSync (/$bunfs/root/claude:12:1864)\n    at XY$ (/$bunfs/root/claude:2213:380)\n    at XY$ (/$bunfs/root/claude:2213:1350)\n    at <anonymous> (/$bunfs/root/claude:2213:4483)\n    at <anonymous> (/$bunfs/root/claude:2213:5171)\n    at A (/$bunfs/root/claude:11:7251)\n    at Z71 (/$bunfs/root/claude:4860:4342)","timestamp":"2026-01-25T03:28:06.698Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.5.content.0: If an assistant message contains any thinking blocks, the first block must be `thinking` or `redacted_thinking`. Found `text`.\"},\"request_id\":\"req_011CXTPxYCGvoJZ711qbqL1F\"}\n    at generate (/$bunfs/root/claude:143:37450)\n    at makeRequest (/$bunfs/root/claude:160:5435)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-01-25T03:36:14.831Z"}]

Activity

  1. github-actions commented on Jan 25, 2026

    @github-actions

    Found 3 possible duplicate issues:

    1. [Bug] Anthropic API Error: Invalid message format with thinking blocks #20691
    2. API Error 400: thinking blocks order error on first tool use after clean install #20692
    3. [BUG] API 400 error: assistant message thinking blocks serialized with text before thinking in conversation replay #20705

    This issue will be automatically closed as a duplicate in 3 days.

    • If your issue is a duplicate, please close it and 👍 the existing issue instead
    • To prevent auto-closure, add a comment or 👎 this comment

    🤖 Generated with Claude Code

  2. cafferychen777 commented on Jan 25, 2026

    @cafferychen777

    This is the same issue as #20717. The root cause is that the client fails to preserve thinking block ordering when constructing API requests with tool calls while thinking mode is enabled. Disabling thinking mode is the only workaround for now.

  3. abose commented on Jan 25, 2026

    @abose
    Author

    I just installed it freshly on a new mac and its happening there too. (same account).

  4. cafferychen777 commented on Jan 25, 2026

    @cafferychen777

    Update: This issue appears to be fixed now!

    Tested with thinking mode + Opus 4.5 — multiple tool calls all succeeded without 400 errors. Please test on your end and confirm!

  5. abose commented on Jan 25, 2026

    @abose
    Author

    Looks like its working now

  6. github-actions commented on Mar 1, 2026

    @github-actions

    Closing for now — inactive for too long. Please open a new issue if this is still relevant.

  7. github-actions commented on Mar 8, 2026

    @github-actions

    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.

  8. locked as resolved and limited conversation to collaborators on Mar 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions