fix(react-a2a): forward user attachments and file parts to the wire#5036
fix(react-a2a): forward user attachments and file parts to the wire#5036ShobhitPatra wants to merge 1 commit into
Conversation
🦋 Changeset detectedLatest commit: 4046fa3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Claude finished @ShobhitPatra's task in 3m 51s —— View job Review — PR #5036 (commit 4046fa3)Verdict: solid fix, no blocking issues. The silent attachment data-loss is real (the old converter read only The head commit is unchanged in substance since the earlier bot reviews (re-push of the same content), so this review focuses on adjudicating the open inline findings from greptile/cubic rather than re-describing the diff. Adjudication of open bot findings1. Non-base64 data URL falls into
Since the previous review already flagged hoisting 2. Zero-byte data URL fails to parse, 3. Suggested improvements
Good practices
SimplifyThe background simplify pass found no efficiency issues and two things worth noting beyond the inline comments already on the PR: Findings (both minor, non-blocking)
The agent also explicitly cleared the things that look like smells but aren't: the |
|
Reviews (1): Last reviewed commit: "fix(react-a2a): forward user attachments..." | Re-trigger Greptile |
There was a problem hiding this comment.
All reported issues were addressed across 6 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
ce7fd67 to
4046fa3
Compare
|
noting the follow-up here so it's tracked with the PR: after this and #5039 merge, one small PR to finish outbound converter part coverage :
kept out of this PR to stay on the reported bug. |
This PR fixes a silent data-loss bug in the A2A adapter where anything a user attached to a message just vanished before the request went out.
What
threadMessageToA2AMessagenow convertsmessage.contentplus each attachment's content parts (withattachment.contentTypeas fallback MIME), delegating to the exportedcontentPartsToA2APartsinstead of keeping a second hand-rolled copy.contentPartsToA2APartsgainsfilepart handling (http URL, data URL, raw base64) and an optional trailingfallbackMimeTypeparameter.{raw, mediaType}with the embedded MIME; plain URLs as{url}plus fallback MIME when known, nomediaTypeotherwise. The oldmediaType: "image/*"is a match pattern, not a valid MIME type.filenamepropagated when present.Why
UseA2ARuntimeOptions.adapters.attachmentsadvertises attachment support and core carriesattachmentsonto the user ThreadMessage, but the converter read onlycontentand handled only text and image, so attached files never reached the server. Both siblings already forward attachment content (adk'sattachments?.flatMap, ag-ui's per-attachment conversion withcontentTypefallback); this mirrors them in a2a's flat part format.The fallback matters concretely:
CloudFileAttachmentAdapteremits image parts as plain http URLs with the real MIME only onattachment.contentType, and file parts that can carrymimeType: "". MIME merging is truthy (||, matching ag-ui) somediaType: ""is never emitted.Impact
image/*only round-tripped as an image by accident of the inboundstartsWith("image/")check; an unknown-MIME URL image now renders inbound as a link, the spec-correct behavior. Extension sniffing was considered and rejected: no repo precedent, and ag-ui also omits MIME for undeclared URL sources.api-surfacesnapshot included, so that CI check is green without an autofix commit.Notes
image/dataskips the part, non-canonical data URLs fall through to url/raw, andmessage.attachments ?? []guards history-loaded messages built via casts that lack the field at runtime despite the type saying required (covered by a test). Pure string handling, safe in Node, react-ink, and React Native.contentPartsToA2APartsremoves a duplicated mapping that had already drifted; behavior verified equivalent.audioattachment parts are still dropped; follow-up.@assistant-ui/react-a2a; fullturbo buildand repo lint pass locally.