Repository navigation
Conversation
…rs (strands-agents#6115) Audio FileParts were converted to DocumentBlocks with a format taken from the MIME subtype, so audio/mpeg came back out as video/mpeg and audio/wav lost its MIME type. MIME parameters such as `; charset=utf-8` also leaked into the document format. Classify audio/* as an AudioBlock, resolve its format through a dedicated audio lookup, and strip parameters before classifying and resolving formats.
3 tasks done
This branch has not been 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.
Human Overview
The problem is that the A2A adapter has been losing audio. So I decided to cut the tails off the MIME type and translate audio/* to the existing audio block. So it is audio on both sides. TS-only fix.
Description
The TypeScript A2A adapter mishandled two kinds of inbound
FileParts:audio/*had no branch in_getFileType, so the part became aDocumentBlockwhose format was the MIME subtype.audio/mpegthen round-tripped asvideo/mpeg, andaudio/wavlost its MIME type.text/plain; charset=utf-8andapplication/pdf; name=xmissed the exact lookup and ended up as document formats"plain; charset=utf-8"and"pdf; name=x".The fix strips parameters (everything after
;, trimmed) before classifying a part and resolving its format, and mapsaudio/*to the existingAudioBlock. Audio gets its own small lookup,toAudioFormat/toAudioMimeTypeinmime.ts, because formats likemp4,webmandmpegare also video formats with different MIME types, so they can't share the existing tables.contentBlocksToPartsnow emitsAudioBlocks as file parts with anaudio/*MIME type.Scope is the TypeScript adapter only. The Python executor (
strands-py/.../a2a/executor.py) has a related but different problem (it can pick the wrong format for parameterized types) and is left for a separate change.Related Issues
Resolves #6115
Documentation PR
None needed.
Type of Change
Bug fix
Testing
Unit tests were added first and failed on
main(10 failures), then pass with the change. Run from the repo root (Node 22):npx vitest run --project unit-node src/a2a src/__tests__/mime.test.ts— 184 passednpm run test— 217 files, 6589 tests passed (8 skipped)npm run lint,npm run format:check— cleannpm run build && npm run type-check— cleanI did not run the integration tests or exercise Bedrock/other providers against the new
AudioBlocks.hatch run prepare(not applicable: TypeScript-only change; the npm checks above were run instead)Additional Details
Extended context (optional)
Round-trip results through
partsToContentBlocks→contentBlocksToParts:audio/mpegaudioBlockmp3audio/mpegaudio/wavaudioBlockwavaudio/wavtext/plain; charset=utf-8documentBlocktxttext/plainapplication/pdf; name=xdocumentBlockpdfapplication/pdfaudio/x-wav,audio/waveaudioBlockwavaudio/wavaudio/mp4audioBlockm4aaudio/mp4Image/PNG ; q=1imageBlockpngimage/png; charset=utf-8documentBlocktxttext/plainAn
audio/*subtype outsideAudioFormat(e.g.audio/x-unknown) is not turned into anAudioBlock; it keeps the previous document path, so behavior for such types is unchanged.The
x-wav/wave,audio/mp4, mixed-case and empty-type rows come from the cases suggested in the issue thread. One more suggestion there, emitting a fallback MIME type for formats without a known mapping (e.g.image/tiffin →tiff→ currently nomimeTypeout), is existing behavior onmainfor images, video and documents alike and is not part of this issue, so I left it out to keep the PR focused. Happy to follow up separately if you want it.Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
This PR was prepared with AI assistance (Claude Code). I reproduced the bug, reviewed the change, and ran the tests myself.