GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — [bug] v0.8.0 Introduced thinking block bug with Claude Sonnet 4: "AI_APICallError: messages.3.content.0.type: Expected `thinking` or `redacted_thinking`, but found `text`." · Issue #2599 · anomalyco/opencode

[bug] v0.8.0 Introduced thinking block bug with Claude Sonnet 4: "AI_APICallError: messages.3.content.0.type: Expected thinking or redacted_thinking, but found text." #2599

New issue
Copy link
New issue
Copy link
Closed
#2602
Closed
[bug] v0.8.0 Introduced thinking block bug with Claude Sonnet 4: "AI_APICallError: messages.3.content.0.type: Expected thinking or redacted_thinking, but found text."#2599
#2602
Copy link
Assignees
thdxr

Description

@grantjayy
grantjayy
opened on Sep 14, 2025
Issue body actions

When using Claude Sonnet 4 with thinking enabled on Opencode v0.8.0, an Anthropic api error happens after tool invocation. Only happens after tool call (specifically read).

This bug is not present in Opencode v0.7.9.

Here is a share URL of the chat context: https://opencode.ai/s/6z4bcRrU

Here is the full API error (not listed in chat context):

AI_APICallError: messages.3.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

Here is my .opencode.json config:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "anthropic": {
      "options": {
        "headers": {
          "anthropic-beta": "context-1m-2025-08-07"
        }
      },
      "models": {
        "claude-opus-4-1-20250805": {
          "limit": {
            "context": 200000,
            "output": 12288
          },
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 1024
            }
          }
        },
        "claude-sonnet-4-20250514": {
          "limit": {
            "context": 1000000,
            "output": 59904
          },
          "options": {
            "thinking": {
              "type": "enabled",
              "budgetTokens": 4096
            }
          }
        }
      }
    }
  },
  "agent": {
    "CSS Tailwind (Build)": {
      "mode": "primary",
      "model": "claude-opus-4-1-20250805",
      "description": "Agent for handling HTML with Tailwind CSS",
      "prompt": "{file:<txt-file>}"
    }
  }
}
Reacted by Arsham Shirvani and Rouven Hi!

Activity

  1. rekram1-node commented on Sep 14, 2025

    @rekram1-node
    rekram1-node
    on Sep 14, 2025
    Member
    More actions

    thanks for raising, looks like it was due to these changes: #2577

    Reacted by Grant Jordan
  2. rekram1-node
    assigned
    rekram1-node
    and
    thdxr
    and unassigned
    rekram1-node
    on Sep 14, 2025
  3. rekram1-node commented on Sep 14, 2025

    @rekram1-node
    rekram1-node
    on Sep 14, 2025
    Member
    More actions

    I think the issue is that "providerOptions": {
    "anthropic": {
    "signature": "...."
    }
    }

    Isn't being saved to the reasoning messages

    shouldn't be hard to fix just need to find where

    Reacted by Arsham Shirvani
  4. rekram1-node
    closed this as completedin #2602on Sep 14, 2025
  5. rekram1-node commented on Sep 14, 2025

    @rekram1-node
    rekram1-node
    on Sep 14, 2025
    Member
    More actions

    should be fixed in next release I tested with quite a few models

    Reacted by Grant Jordan
  6. monotykamary
    added a commit that references this issue on Sep 15, 2025

    fix(session): pair reasoning with following text in prompts\n\nPreven…

    3c990d0
  7. jessevdp commented on Oct 2, 2025

    @jessevdp
    jessevdp
    on Oct 2, 2025
    Contributor
    More actions

    I'm running into a similar issue with Claude 4.5 Sonnet hosted on Google Vertex (through openai-compatible proxy: LiteLLM...)

    messages.3.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
    
    {
      "type": "error",
      "error": {
        "type": "invalid_request_error",
        "message": "messages.3.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": "..."
    }

    Should I open a separate issue?

  8. VisionaryOS commented on Dec 27, 2025

    @VisionaryOS
    VisionaryOS
    on Dec 27, 2025
    More actions

    still running into this frequently "messages.101: The final block in an assistant message cannot be thinking" every few tasks with claude opus in opencode

  9. rekram1-node commented on Dec 27, 2025

    @rekram1-node
    rekram1-node
    on Dec 27, 2025
    Member
    More actions

    @VisionaryOS can u share a session?

    opencode export > session.json

  10. Alumniminium commented on Jan 7, 2026

    @Alumniminium
    Alumniminium
    on Jan 7, 2026
    More actions

    messages.581.content.0: When thinking is disabled, an assistantmessage in the final position cannot containthinking. To use thinking blocks, enable thinking in your request.

    getting this constantly with claude opus with thinking mode on, usually after it calls MCPs, the next message has <thinking> tags visible and then when it stops generating, the error pops

    I think this is somehow related to plugins and noReply/ignore messages.

  11. sssgun
    added a commit that references this issue on Jan 18, 2026

    feat: add two-layer thinking block validation (proactive + reactive) (c…

    c079aa1
  12. Rolloniel
    added a commit that references this issue on Feb 22, 2026

    feat: add two-layer thinking block validation (proactive + reactive) (c…

    ae1399c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @thdxr
    thdxr

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.