Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/claude_agent_sdk/_internal/message_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def parse_message(data: dict[str, Any]) -> Message | None:
content_blocks.append(
ThinkingBlock(
thinking=block["thinking"],
signature=block["signature"],
signature=block.get("signature", ""),
)
)
case "tool_use":
Expand Down
23 changes: 23 additions & 0 deletions tests/test_message_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,29 @@ def test_parse_assistant_message_with_thinking(self):
assert isinstance(message.content[1], TextBlock)
assert message.content[1].text == "Here's my response"

def test_parse_assistant_message_with_thinking_missing_signature(self):
"""Test parsing an assistant message with thinking block missing signature."""
data = {
"type": "assistant",
"message": {
"content": [
{
"type": "thinking",
"thinking": "Redacted thinking content",
},
{"type": "text", "text": "Here's my response"},
],
"model": "claude-opus-4-1-20250805",
},
}
message = parse_message(data)
assert isinstance(message, AssistantMessage)
assert len(message.content) == 2
assert isinstance(message.content[0], ThinkingBlock)
assert message.content[0].thinking == "Redacted thinking content"
assert message.content[0].signature == ""
assert isinstance(message.content[1], TextBlock)

def test_parse_assistant_message_with_usage(self):
"""Per-turn usage is preserved on AssistantMessage.

Expand Down