Revert "Added fix to always convert all items of a content list to content blocks"

This reverts commit 1b49523e01.
This commit is contained in:
Josh Rubin 2025-09-30 14:32:30 -04:00
commit 87e31cc544
No known key found for this signature in database
GPG key ID: EC9084A87D276C99

View file

@ -544,10 +544,15 @@ def _convert_to_content(
if all(isinstance(item, ContentBlock) for item in result):
return result
# Convert items that are not ContentBlocks
return [
_convert_to_single_content_block(item, serializer)
if not isinstance(item, ContentBlock)
else item
for item in result
]
# If any item is a ContentBlock, convert non-ContentBlock items to TextContent
# without aggregating them
if any(isinstance(item, ContentBlock) for item in result):
return [
_convert_to_single_content_block(item, serializer)
if not isinstance(item, ContentBlock)
else item
for item in result
]
# If none of the items are ContentBlocks, aggregate all items into a single TextContent
return [TextContent(type="text", text=_serialize_with_fallback(result, serializer))]