anthropics / anthropics/anthropic-sdk-python
[Bug] API returns 400 'Invalid signature in thinking block' when replaying conversation history — no recovery path
- 主要言語
- Python
- スター
- 3.9k
- フォーク
- 853
- 平均マージ
- 1日 18時間
- マージ済み PR(30日)
- 11
説明
## Bug Description
When using extended thinking with claude-sonnet-4.x/claude-opus-4.x in a multi-turn conversation, the API begins returning `400: Invalid `signature` in `thinking` block` after N turns. Once triggered, **every subsequent message in the session fails permanently** — there is no recovery without manually stripping thinking blocks from history.
## Reproduction
1. Enable extended thinking on claude-sonnet-4-6 or claude-opus-4
2. Run a long multi-turn conversation (20+ turns with tool use)
3. Pass full conversation history on each turn (including `type: "thinking"` blocks from prior assistant messages)
4. At some turn, the API begins rejecting with 400: `messages.X.content.Y: Invalid `signature` in `thinking` block`
5. The position (X, Y) is consistent — the same thinking block triggers it every time
6. The session cannot recover — every subsequent call with that history fails
## Error
```json
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "messages.27.content.0: Invalid `signature` in `thinking` block"
}
}
```
## Questions / Issues
1. **What invalidates a signature?** The API docs say to pass thinking blocks back unmodified. If signatures expire or become invalidated server-side, clients have no way to know without trying.
2. **No recovery path** — the error is a hard 400, not retryable. Clients must strip thinking blocks from history to continue, but the API docs don't describe this scenario or recommend this workaround.
3. **Cascading failure** — subagents or forked sessions that inherit the conversation history also fail immediately.
## Environment
- SDK: used via OpenClaw gateway (direct Anthropic REST API)
- Model: claude-sonnet-4-6
- Platform: macOS 26.4.1, Node.js 22.x
## Related
- anthropics/claude-code#21726 (session resume fails with same error)
- anthropics/claude-code#10627
## Requested
1. Document under what conditions a thinking block signature becomes invalid
2. Provide a recommended recovery path (e.g., strip thinking blocks from history on 400, retry)
3. Ideally: return a more specific error type so clients can handle it programmatically
コントリビューションガイド
評価
この issue はまだ評価されていません。