fix: no null's in is_error
This commit is contained in:
@@ -398,12 +398,17 @@ def _block_to_dict(block: ContentBlock) -> dict[str, Any]:
|
|||||||
"input": block.input,
|
"input": block.input,
|
||||||
}
|
}
|
||||||
if isinstance(block, ToolResultBlock):
|
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",
|
"type": "tool_result",
|
||||||
"tool_use_id": block.tool_use_id,
|
"tool_use_id": block.tool_use_id,
|
||||||
"content": block.content,
|
"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):
|
if isinstance(block, ThinkingBlock):
|
||||||
return {
|
return {
|
||||||
"type": "thinking",
|
"type": "thinking",
|
||||||
|
|||||||
Reference in New Issue
Block a user