anthropics / anthropics/claude-agent-sdk-python
MessageParseError: missing signature in thinking block with claude-agent-sdk 0.1.79 and Anthropic-compatible backend
- 主要語言
- Python
- 星號
- 8.1k
- 分支
- 1.3k
- 平均合併
- 2 天 31 分鐘
- 30 天內合併 PR
- 1
描述
## Summary
claude-agent-sdk crashes with:
```
claude_agent_sdk._errors.MessageParseError:
Missing required field in assistant message: 'signature'
```
This is similar to #339, but I can still reproduce it with `claude-agent-sdk==0.1.79`.
The issue appears when the model/backend emits a `thinking` content block without a `signature` field. The SDK parser currently assumes every thinking block has `signature`.
## Environment
- OS: Linux / Docker
- Python: 3.11
- claude-agent-sdk: 0.1.79
- Runtime: Docker container
- Model: `gpt-5.4` via Anthropic-compatible backend
- SDK entrypoint: `claude_agent_sdk.query(...)`
- `ClaudeAgentOptions` includes:
- `model="gpt-5.4"`
- `allowed_tools=[...]`
- `permission_mode="dontAsk"`
- `skills=[...]`
- `resume=` sometimes true
SDK inspection output:
```
sdk_version = 0.1.79
parser_file = /usr/local/lib/python3.11/site-packages/claude_agent_sdk/_internal/message_parser.py
100: case "thinking":
103: thinking=block["thinking"],
104: signature=block["signature"]
```
## Reproduction
This is reproducible in our bot when the user sends a repository URL, for example:
- `https://github.com/anthropics/claude-agent-sdk-python`
- or a GitLab repository URL
The request runs for ~30 seconds, then fails before any final assistant result is returned.
## Actual behavior
The SDK raises `MessageParseError` while parsing an assistant message:
```
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/claude_agent_sdk/_internal/message_parser.py", line 137, in parse_message
signature=block["signature"],
KeyError: 'signature'
The above exception was the direct cause of the following exception:
claude_agent_sdk._errors.MessageParseError:
Missing required field in assistant message: 'signature'
```
Service logs:
```
claude sdk event type=SystemMessage resume=True
...
MessageParseError: Missing required field in assistant message: 'signature'
```
## Expected behavior
The SDK should not crash the whole query when a thinking block is missing `signature`.
Possible acceptable behaviors:
1. If `signature` is required only for Anthropic native thinking blocks, **document** that non-Anthropic-compatible backends must disable thinking.
2. Provide a **clearer error message** explaining that the backend emitted an invalid/incompatible thinking block.
3. Allow `ClaudeAgentOptions(thinking={"type": "disabled"})` to reliably prevent such blocks from being emitted/parsed.
4. Optionally parse unsigned thinking blocks as a **best-effort compatibility mode**, or expose a config flag for strict vs permissive parsing.
## Related
- #339 — closed not planned, but reproducible on the latest version (0.1.79).
- #473 — similar `KeyError: signature` from the CLI side.
- #786 — proposes `block.get("signature", "")`; would silence the crash but produce empty-signature blocks that may still fail on multi-turn round-trips.
貢獻指南
這個儲存庫沒有索引到貢獻指南
評估
這個 Issue 還沒有評估資料。