Repository navigation
Python: Default A2A raw parts without a media type to application/octet-stream - #10251
Open
ni (nniiovoo) wants to merge 1 commit into
Open
ni (nniiovoo) wants to merge 1 commit into
ni (nniiovoo) wants to merge 1 commit into
Conversation
…et-stream Signed-off-by: NNIIOVO <haimingni44@gmail.com>
Contributor
There was a problem hiding this comment.
🟢 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
2 tasks done
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation & Context
A raw A2A file part without
media_typebecame data content with the URIdata:;base64,.... Sending that content on to another A2A agent, or serving it throughA2AExecutor, then failed inget_uri_datawithValueError: Invalid data URI format. Repro is in #10250.Description & Review Guide
_parse_contents_from_a2a, a raw part with no media type now getsapplication/octet-streaminstead of an empty string. The AG-UI message adapter uses the same default.get_uri_datainstead (acceptdata:;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
AI assistance details: issue analysis, implementation, tests, and this description.
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.