## Bug: Invalid `signature` in `thinking` block on multi-turn conversations with extended thinking enabled
**Severity:** High — breaks all multi-turn conversations when extended thinking is active
**Component:** Conversation history / message assembly
**API:** Anthropic Messages API (`/v1/messages`)
---
### Description
When extended thinking is enabled, multi-turn conversations fail with a 400 error on the second request:
API Error: 400 {"type":"error","error":{"type":"invalid_request_error",
"message":"messages.1.content.0: Invalid signature in thinking block"}}
### Root Cause
The Anthropic API requires that `thinking` blocks in assistant messages are passed back **verbatim** in subsequent requests. Each `thinking` block contains a `signature` field that the API uses to verify the content has not been tampered with between turns.
OpenWolf appears to be mangling the assistant message content when building conversation history — likely by:
- Deserialising/reserialising message content and dropping the `signature` field
- Extracting only `type: "text"` blocks and discarding `thinking` blocks
- Reconstructing or summarising assistant content rather than storing/replaying it as-is
The result is a `thinking` block with a missing or empty `signature` being sent back to the API:
```json
{
"type": "thinking",
"thinking": "...",
"signature": ""
}
```
### Expected Behaviour
Assistant message content arrays (including `thinking` blocks) must be stored and replayed exactly as received from the API. The `signature` field is non-negotiable — it cannot be omitted, emptied, or regenerated.
Per Anthropic's documentation, there are only two valid approaches for handling `thinking` blocks in conversation history:
1. **Pass them back whole** — store the entire content block including `type`, `thinking`, and `signature`, and include it verbatim in subsequent turns.
2. **Omit them entirely** — the API permits dropping `thinking` blocks from prior turns in the history. What it does not permit is including them with an invalid or missing `signature`.
### Steps to Reproduce
1. Enable extended thinking in settings
2. Start a new conversation and send any message
3. Send a follow-up message in the same conversation
**Result:** 400 error on the second request
**Expected:** Successful response
### Suggested Fix
In the message history assembly layer, ensure assistant messages are stored as the complete raw content array returned by the API — not reconstructed or filtered. When replaying history, either include `thinking` blocks exactly as stored, or strip them entirely before sending. Do not include them in a partially reconstructed state.
### Environment
- OpenWolf version: 1.0.4
- Extended thinking: enabled
- Model: Sonnet 4.6
API Error: 400 {"type":"error","error":{"type":"invalid_request_error",
"message":"messages.1.content.0: Invalid
signatureinthinkingblock"}}