Skip to content

Python: Accept input_file file_data in the Responses hosting parser - #10284

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
nniiovoo:python-hosting-responses-input-file-data
Nov 12, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 1 commit into
microsoft:mainfrom
nniiovoo:python-hosting-responses-input-file-data

Conversation

@nniiovoo

Copy link
Copy Markdown
Contributor

Motivation & Context

The Responses hosting parser rejected input_file parts with inline file_data, which is what OpenAIChatClient sends for a local file. So Agent Framework's own OpenAI client couldn't send a PDF to an agent hosted with agent-framework-hosting-responses. Repro is in #10283.

Description & Review Guide

  • What are the major changes? _content_from_input_item gets a file_data branch next to file_url and file_id. A data URI becomes data content as is. Plain base64 (no data: prefix) is wrapped in a data URI, with the media type guessed from filename or application/octet-stream. The payload is checked with base64.b64decode(validate=True), and a bad or non-base64 value raises ValueError like the other malformed inputs.
  • What is the impact of these changes? Requests with inline files are accepted instead of returning an error. file_url and file_id parts are unchanged and still take precedence if more than one is sent.
  • What do you want reviewers to focus on? Whether plain base64 should be accepted at all. The OpenAI client always sends a data URI, but its own output parser accepts both forms, so I did the same here.

Tests: I added tests for file_data as a data URI and as plain base64 (they fail on main), the application/octet-stream fallback, and malformed or non-base64 values.

Related Issue

Fixes #10283

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 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.

Signed-off-by: NNIIOVO <haimingni44@gmail.com>

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

No active review issues remain for the inline file-data parsing change.

No open issues 🎉

What changed in this PR

Adds inline file_data support to the Python Responses hosting parser, allowing hosted agents to receive local files sent by OpenAIChatClient and addressing #10283.

Changes:

  • Accepts base64 data URIs and plain base64, inferring the latter’s media type from the filename with an application/octet-stream fallback.
  • Validates base64 payloads while preserving existing file_url and file_id precedence.
  • Adds tests for supported formats, media-type fallback, and invalid inputs.
File Description
python/​packages/​hosting-responses/​tests/​hosting_responses/​test_parsing.py Tests inline file parsing and malformed-input rejection.
python/​packages/​hosting-responses/​agent_framework_hosting_responses/​_parsing.py Adds inline file decoding validation and data-content conversion.

Review effort: Balanced

Merged via the queue into microsoft:main with commit 2d2851c Nov 12, 2026
58 of 59 checks passed

This branch was successfully deployed

1 active deployment
github-app-auth — 714e2be8 Deployed Nov 11, 2026 by nniiovoo via team_check #9310
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]: Responses hosting rejects input_file with file_data, which OpenAIChatClient sends for local files

3 participants