Repository navigation
Python: Send images in user messages to Bedrock Converse instead of dropping them - #8683
Conversation
…ropping them _convert_content_to_bedrock_block only handled text, function_call and function_result, so image data content (Content.from_data with an image/* media type) was skipped with a debug log and the model answered without seeing the image. Map image data content to a Converse image block with raw bytes, the same way the Anthropic client maps image data to its image block. Images in non-user messages and other data types are still skipped as before. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Image formats require validation, and the private helper import needs its required Pyright suppression.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Adds Bedrock Converse support for images in user messages while preserving existing behavior for assistant images.
Changes:
- Converts PNG/JPEG user image data into Converse image blocks.
- Adds regression coverage for user and assistant image handling.
| File | Description |
|---|---|
python/packages/bedrock/agent_framework_bedrock/_chat_client.py |
Adds Bedrock image-block conversion and role filtering. |
python/packages/bedrock/tests/test_bedrock_client.py |
Tests image conversion and assistant-image skipping. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Converse only accepts gif, jpeg, png and webp image blocks. Sending the raw media subtype made image/jpg, upper-case types such as IMAGE/PNG, and formats like image/bmp or image/svg+xml fail the whole request with a ValidationException. Lower-case the subtype and map jpg to jpeg. Other formats are skipped with a warning, like other content this client cannot send, so the rest of the message still goes through. Co-Authored-By: Claude <noreply@anthropic.com>
Eduard van Valkenburg (eavanvalkenburg)
left a comment
There was a problem hiding this comment.
Lucas Kim (@kimnamu) The current head is green, and the dedicated full-diff review found no remaining actionable issues with Bedrock user-image forwarding, user-role filtering, supported-format validation, unsupported-format handling, or the accompanying regression coverage.

Motivation & Context
Thanks for the Bedrock connector and for the Anthropic client's image mapping, which this PR mirrors. User-message images were skipped before Converse, so GPT-6 Sol/Luna/Astra answered blind.
Description & Review Guide
case "data" if content.has_top_level_media_type("image")branch returns a Converseimageblock via the existing_get_data_bytes(as Gemini does). Images outside user messages stay skipped. Tests cover png/jpeg (fail without the fix) and an assistant image.us.openai.gpt-6-sol'Unknown.', blocks sent['text']'Red', blocks sent['text', 'image']us.openai.gpt-6-luna'Gray', blocks sent['text']'Red', blocks sent['text', 'image']us.openai.gpt-5.6-sol'Unknown''Red'us.openai.gpt-6-astra'Unknown.', blocks sent['text']'Red.', blocks sent['text', 'image']global.openai.gpt-6-astra'Unknown', blocks sent['text']'Red', blocks sent['text', 'image']application/octet-stream,text/plain)jpgmapped tojpeg. Subtypes Converse doesn't accept (its enum is[gif, jpeg, png, webp]), such asimage/bmporimage/svg+xml, are skipped with a warning like other content this client can't send, so the text still goes through.Related Issue
Fixes #8682
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.