Skip to content

Python: fix(hosting-responses): keep the media type of input_image data URLs - #9298

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
shanto462:fix-responses-input-image-data-url
Oct 12, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
shanto462:fix-responses-input-image-data-url

Conversation

@shanto462

@shanto462 Md. Shalah Uddin (shanto462) commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Motivation & Context

messages_from_responses_input gave every input_image the media type image/*, also when image_url is a data URL that declares its own type. Chat clients use that media type for base64 images: AnthropicClient sent image/*, which is not an accepted image type, and BedrockChatClient dropped the image. So images sent as data URLs to an agent behind the Responses host were rejected or lost.

Description & Review Guide

  • What are the major changes? For a data:image/... URL the parser no longer passes media_type="image/*", so Content.from_uri keeps the type written in the data URL. All other URLs still get image/*. Regression tests cover the string and object forms of image_url, and check that an https URL still gets image/*.
  • What is the impact of these changes? Images sent as data URLs reach the chat client with their real type (for example image/png). Nothing changes for http(s) URLs, file_id images, or data URLs that do not declare an image type.
  • What do you want reviewers to focus on? The check is startswith("data:image/"), not startswith("data:") as in the chatkit converter. With data:, a data URL without a type (data:;base64,...) would get the RFC 2397 default text/plain and stop being treated as an image, so those keep image/* as before.

Related Issue

Fixes #9295

No other open PR covers this issue.

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: issue analysis, implementation, tests, and this PR description.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Copilot AI balanced review requested due to automatic review settings October 12, 2026 10:37
@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Oct 12, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The focused implementation matches the intended behavior and includes coverage for affected and unchanged paths.

0 open findings

What changed in this PR

Fixes Responses hosting so image data URLs retain their declared media type.

Changes:

  • Preserves media types such as image/png for image data URLs.
  • Adds regression coverage for string, object, and HTTPS image URLs.
File Description
python/​packages/​hosting-responses/​agent_framework_hosting_responses/​_parsing.py Retains declared data-URL image types.
python/​packages/​hosting-responses/​tests/​hosting_responses/​test_parsing.py Tests data and HTTPS image URL handling.

🧠 Review effort: Balanced


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Merged via the queue into microsoft:main with commit 2d58876 Oct 12, 2026
58 checks passed
@shanto462
Md. Shalah Uddin (shanto462) deleted the fix-responses-input-image-data-url branch October 19, 2026 09:42

This branch was previously deployed

1 inactive deployment
github-app-auth — 3d5a6316 Deployed Oct 12, 2026 by shanto462 via add_label #24994
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: hosting-responses replaces the media type of input_image data URLs with image/*

3 participants