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=<session_id> 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:
- If
signature is required only for Anthropic native thinking blocks, document that non-Anthropic-compatible backends must disable thinking.
- Provide a clearer error message explaining that the backend emitted an invalid/incompatible thinking block.
- Allow
ClaudeAgentOptions(thinking={"type": "disabled"}) to reliably prevent such blocks from being emitted/parsed.
- Optionally parse unsigned thinking blocks as a best-effort compatibility mode, or expose a config flag for strict vs permissive parsing.
Related
Summary
claude-agent-sdk crashes with:
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
thinkingcontent block without asignaturefield. The SDK parser currently assumes every thinking block hassignature.Environment
gpt-5.4via Anthropic-compatible backendclaude_agent_sdk.query(...)ClaudeAgentOptionsincludes:model="gpt-5.4"allowed_tools=[...]permission_mode="dontAsk"skills=[...]resume=<session_id>sometimes trueSDK inspection output:
Reproduction
This is reproducible in our bot when the user sends a repository URL, for example:
https://github.com/anthropics/claude-agent-sdk-pythonThe request runs for ~30 seconds, then fails before any final assistant result is returned.
Actual behavior
The SDK raises
MessageParseErrorwhile parsing an assistant message:Service logs:
Expected behavior
The SDK should not crash the whole query when a thinking block is missing
signature.Possible acceptable behaviors:
signatureis required only for Anthropic native thinking blocks, document that non-Anthropic-compatible backends must disable thinking.ClaudeAgentOptions(thinking={"type": "disabled"})to reliably prevent such blocks from being emitted/parsed.Related
KeyError: signaturefrom the CLI side.block.get("signature", ""); would silence the crash but produce empty-signature blocks that may still fail on multi-turn round-trips.