anthropics / anthropics/claude-agent-sdk-python

MessageParseError: missing signature in thinking block with claude-agent-sdk 0.1.79 and Anthropic-compatible backend

Open
#949 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
8.1k
Forks
1.3k
Avg merge
2d 31m
Merged PRs (30d)
1

Description

## 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.