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>}"
}
}
}