Skip to content

Python: Default A2A raw parts without a media type to application/octet-stream - #10251

Open
ni (nniiovoo) wants to merge 1 commit into
microsoft:mainfrom
nniiovoo:python-a2a-file-no-media-type
Open

ni (nniiovoo) wants to merge 1 commit into
microsoft:mainfrom
nniiovoo:python-a2a-file-no-media-type

Conversation

@nniiovoo

Copy link
Copy Markdown
Contributor

Motivation & Context

A raw A2A file part without media_type became data content with the URI data:;base64,.... Sending that content on to another A2A agent, or serving it through A2AExecutor, then failed in get_uri_data with ValueError: Invalid data URI format. Repro is in #10250.

Description & Review Guide

  • What are the major changes? In _parse_contents_from_a2a, a raw part with no media type now gets application/octet-stream instead of an empty string. The AG-UI message adapter uses the same default.
  • What is the impact of these changes? Files received without a media type can be passed on to other A2A agents. Parts that have a media type are unchanged, and URL-part handling is unchanged.
  • What do you want reviewers to focus on? Whether you'd rather fix it in get_uri_data instead (accept data:;base64,...). I went with the parser so unknown raw files have an explicit generic binary media type.

Tests: I added a test that parses a raw part without a media type and sends it back through _prepare_message_for_a2a (it fails on main).

Related Issue

Fixes #10250

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.

…et-stream

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 are reported for the change introducing a binary default for raw file parts without a media type.

No open issues 🎉

What changed in this PR

Fixes #10250 by giving incoming A2A raw file parts without a media type a valid binary default, allowing them to be forwarded without an invalid data URI error.

Changes:

  • Default missing raw-part media types to application/octet-stream, leaving explicit media types and URL parts unchanged.
  • Add a regression test that parses a raw file without a media type and verifies its bytes survive conversion back to an A2A message.
File Description
python/​packages/​a2a/​tests/​test_a2a_agent.py Adds round-trip coverage for raw files without a media type.
python/​packages/​a2a/​agent_framework_a2a/​_agent.py Applies the binary media-type default when parsing raw parts.

Review effort: Balanced

This branch was successfully deployed

1 active deployment
github-app-auth — 94367cd9 Deployed Nov 10, 2026 by nniiovoo via team_check #9231
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]: A2A file part without media_type becomes "data:;base64,..." and can't be sent on

2 participants