You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Python: [Bug]: Anthropic connector silently drops ImageContent in user messages and crashes on image-only requests #14531
This causes two major issues when interacting with multimodal Anthropic Claude models (such as Claude 3.5 Sonnet, Claude 3.7 Sonnet, Claude Opus 4.8, Claude Fable 5.1 / Mythos 5.1):
Silent Image Data Loss: If a user message contains ImageContent along with text in message.items, the image items are completely discarded and only the text content is sent to Anthropic.
API Crash on Image-Only Messages: If a user message contains only ImageContent without text, message.content is empty/None, causing Anthropic API to return a 400 Bad Request: messages: at least one content block is required error.
Other connectors (Google AI, Vertex AI, AWS Bedrock) iterate over message.items to format ImageContent. Anthropic connector should support this as well.
Steps to Reproduce
fromsemantic_kernel.contents.chat_message_contentimportChatMessageContentfromsemantic_kernel.contents.image_contentimportImageContentfromsemantic_kernel.contents.text_contentimportTextContentfromsemantic_kernel.contents.utils.author_roleimportAuthorRolefromsemantic_kernel.connectors.ai.anthropic.services.utilsimport_format_user_messagemsg=ChatMessageContent(
role=AuthorRole.USER,
items=[
TextContent(text="Analyze this image"),
ImageContent(data_uri="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="),
],
)
formatted=_format_user_message(msg)
# formatted['content'] is "Analyze this image" -- image was completely discarded!
Expected Behavior
_format_user_message should inspect message.items and format ImageContent into Anthropic's native {"type": "image", "source": {"type": "base64", ...}} content blocks.
changed the title [-][Bug]: Anthropic connector silently drops ImageContent in user messages and crashes on image-only requests[/-][+].Net: [Bug]: Anthropic connector silently drops ImageContent in user messages and crashes on image-only requests[/+]on Oct 3, 2026
changed the title [-].Net: [Bug]: Anthropic connector silently drops ImageContent in user messages and crashes on image-only requests[/-][+]Python: [Bug]: Anthropic connector silently drops ImageContent in user messages and crashes on image-only requests[/+]on Oct 3, 2026
Update: I found PR #14532 linked to this issue after posting; it already addresses data-backed image content, so I will not submit a duplicate implementation PR. I left a focused comment on #14532 about the URI-only ImageContent case because the type permits URI-only instances and Anthropic supports URL image sources. I will wait for feedback on whether that case is in scope before preparing any follow-up.
Activity
[-][Bug]: Anthropic connector silently drops ImageContent in user messages and crashes on image-only requests[/-][+].Net: [Bug]: Anthropic connector silently drops ImageContent in user messages and crashes on image-only requests[/+][-].Net: [Bug]: Anthropic connector silently drops ImageContent in user messages and crashes on image-only requests[/-][+]Python: [Bug]: Anthropic connector silently drops ImageContent in user messages and crashes on image-only requests[/+]ducanhnguyen223 commentedon Oct 3, 2026
Update: I found PR #14532 linked to this issue after posting; it already addresses data-backed image content, so I will not submit a duplicate implementation PR. I left a focused comment on #14532 about the URI-only ImageContent case because the type permits URI-only instances and Anthropic supports URL image sources. I will wait for feedback on whether that case is in scope before preparing any follow-up.