fix: no null's in is_error

This commit is contained in:
h
2026-05-21 13:00:40 +02:00
parent 1f20cef7d4
commit 86d8a8f4c4
+7 -2
View File
@@ -398,12 +398,17 @@ def _block_to_dict(block: ContentBlock) -> dict[str, Any]:
"input": block.input,
}
if isinstance(block, ToolResultBlock):
return {
# ``is_error`` is optional on the wire; emitting ``null`` makes the
# Anthropic API reject the message with "Input should be a valid
# boolean". Omit it entirely when we don't have a value.
result: dict[str, Any] = {
"type": "tool_result",
"tool_use_id": block.tool_use_id,
"content": block.content,
"is_error": block.is_error,
}
if block.is_error is not None:
result["is_error"] = block.is_error
return result
if isinstance(block, ThinkingBlock):
return {
"type": "thinking",