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." #2599DescriptionWhen 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! Activityrekram1-node commented on Sep 14, 2025 thanks for raising, looks like it was due to these changes: #2577 rekram1-node commented on Sep 14, 2025 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 rekram1-node commented on Sep 14, 2025 should be fixed in next release I tested with quite a few models jessevdp commented on Oct 2, 2025 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? VisionaryOS commented on Dec 27, 2025 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 rekram1-node commented on Dec 27, 2025 @VisionaryOS can u share a session?
opencode export > session.json Alumniminium commented on Jan 7, 2026 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.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|