Skip to content

fix(a2a): map audio file parts to AudioBlock and ignore MIME parameters - #6164

Open
mccalpink wants to merge 1 commit into
strands-agents:mainfrom
mccalpink:fix/6115-a2a-audio-mime-params
Open

mccalpink wants to merge 1 commit into
strands-agents:mainfrom
mccalpink:fix/6115-a2a-audio-mime-params

Conversation

@mccalpink

@mccalpink mccalpink commented Nov 15, 2026 •

Copy link
Copy Markdown

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. audio/* had no branch in _getFileType, so the part became a DocumentBlock whose format was the MIME subtype. audio/mpeg then round-tripped as video/mpeg, and audio/wav lost its MIME type.
  • MIME parameters. text/plain; charset=utf-8 and application/pdf; name=x missed 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 maps audio/* to the existing AudioBlock. Audio gets its own small lookup, toAudioFormat / toAudioMimeType in mime.ts, because formats like mp4, webm and mpeg are also video formats with different MIME types, so they can't share the existing tables. contentBlocksToParts now emits AudioBlocks as file parts with an audio/* 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 passed
  • npm run test — 217 files, 6589 tests passed (8 skipped)
  • npm run lint, npm run format:check — clean
  • npm run build && npm run type-check — clean

I did not run the integration tests or exercise Bedrock/other providers against the new AudioBlocks.

  • I ran 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:

in block format out
audio/mpeg audioBlock mp3 audio/mpeg
audio/wav audioBlock wav audio/wav
text/plain; charset=utf-8 documentBlock txt text/plain
application/pdf; name=x documentBlock pdf application/pdf
audio/x-wav, audio/wave audioBlock wav audio/wav
audio/mp4 audioBlock m4a audio/mp4
Image/PNG ; q=1 imageBlock png image/png
; charset=utf-8 documentBlock txt text/plain

An audio/* subtype outside AudioFormat (e.g. audio/x-unknown) is not turned into an AudioBlock; 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/tiff in → tiff → currently no mimeType out), is existing behavior on main for 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

  • I have read the CONTRIBUTING document
  • I have reviewed and understand every line of code in this PR, including any generated by AI tools, and I can explain why it works
  • My change is focused and reasonably small; I have split unrelated work into separate PRs
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly (no docs change needed)
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

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.

…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.
@mccalpink
mccalpink requested a review from a team as a code owner November 15, 2026 22:44
@mccalpink
mccalpink requested a review from liramon2 November 15, 2026 22:44
@github-actions github-actions Bot added bug Something isn't working area-a2a A2A Related typescript Pull requests that update typescript code labels Nov 15, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-a2a A2A Related bug Something isn't working typescript Pull requests that update typescript code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] A2A adapter: audio parts round trip as video/mpeg, and MIME parameters leak into document format

1 participant