Skip to content

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

@googs1025

Description

@googs1025

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:

  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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions