Skip to content

Claude extended thinking + tool use: signature not preserved in message history #6176

@codewithkenzo

Description

@codewithkenzo

Description

When using Claude models with extended thinking (e.g., claude-opus-4-5-thinking, claude-4-5-sonnet with thinking enabled) via custom providers (like oh-my-opencode's Antigravity), multi-turn conversations with tool use fail with:

messages.X.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).

Root Cause

Claude's API requires:

  1. When thinking is enabled, every assistant message must start with a thinking block
  2. Thinking blocks in message history MUST include the signature field (returned by Claude in original response)

The signature appears to not be preserved when storing assistant messages in OpenCode's message history. When the message is sent back in subsequent requests, the thinking block is either:

  • Missing entirely, OR
  • Missing the required signature field

Related Issues

Expected Behavior

When Claude returns:

{
  "content": [
    { "type": "thinking", "thinking": "...", "signature": "abc123..." },
    { "type": "tool_use", "id": "...", "name": "bash", "input": {...} }
  ]
}

The signature field should be preserved in message history so it can be sent back in subsequent requests.

Workaround

For oh-my-opencode users, I've submitted a PR that strips unsigned thinking blocks from history to prevent the API error: code-yeongyu/oh-my-opencode#253

This is a workaround, not a fix - the proper fix is to preserve signatures in OpenCode's message storage.

Environment

  • OpenCode version: 1.0.x (latest)
  • Provider: Custom (oh-my-opencode Antigravity)
  • Model: claude-opus-4-5-thinking, claude-4-5-sonnet with thinking
  • OS: Linux

Metadata

Metadata

Assignees

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