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,
|
||||
}
|
||||
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",
|
||||
|
||||
Reference in New Issue
Block a user