Skip to content

fix(samples): put the MIME type in part metadata in the Lit and React clients - #3602

Open
retz8 wants to merge 5 commits into
a2ui-project:mainfrom
retz8:fix/sample-clients-mime-type-metadata
Open

retz8 wants to merge 5 commits into
a2ui-project:mainfrom
retz8:fix/sample-clients-mime-type-metadata

Conversation

@retz8

@retz8 retz8 commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Description

The Lit shell's A2UIClient and the React shell's A2A middleware set mimeType on the data part itself, not in its metadata. The Python a2a-sdk drops that field, so is_a2ui_part returns False for every client event these shells send. Full mechanism and reproduction in the issue. Fixes #3601.

Fix

{
  kind: 'data',
  data: clientEvent,
  metadata: {mimeType: A2UI_MIME_TYPE},
},
  • samples/client/lit/shell/client.ts: both client-event parts, and the {useStreaming: false} part, which set mimeType: 'application/json' the same way.
  • samples/client/react/shell/middleware/a2a.ts: the client-event part. The file no longer imports Part.

The parts now match the extension specs' examples, the Angular client and the Lit shell's own middleware. The as Part casts are gone, so the compiler checks the part's shape. A mimeType on the part now fails with TS2353: Object literal may only specify known properties, and 'mimeType' does not exist in type 'DataPart'.

The sample agents find events by the keys inside data, so they behave as before.

Tests

Neither shell has a test that covers sending. I ran an a2a-sdk 0.3.25 agent on localhost:10002 that logs each DataPart it receives. I sent one client event through the Lit shell's A2UIClient in Node and POSTed one to the React shell's /a2a on the Vite dev server:

Part main This branch
Lit, client event metadata is None; is_a2ui_part is False metadata is {"mimeType": "application/a2ui+json"}; is_a2ui_part is True
Lit, useStreaming part metadata is None metadata is {"mimeType": "application/json"}
React, client event metadata is None; is_a2ui_part is False metadata is {"mimeType": "application/a2ui+json"}; is_a2ui_part is True

On this branch:

  • tsc --noEmit passes for both shells (Lit after building @a2ui/lit).
  • The Lit shell's smoke test (vitest run --environment jsdom tests/smoke-test.spec.ts) passes.
  • ESLint reports no errors on the two files. Lit's three existing no-explicit-any warnings, on lines this PR does not touch, remain.
  • Prettier is clean.

Pre-launch Checklist

One time:

For this PR:

  • I have updated the relevant CHANGELOG.md file.
  • I updated/added relevant documentation.
  • My code changes (if any) have tests.
  • If my branch is on a fork, I have verified that scripts/e2e_test.sh passes.

If you need help, consider asking for advice on the discussion board.

… clients

The Lit shell's A2UIClient and the React shell's A2A middleware set
`mimeType` on the data part itself, beside `kind` and `data`, and cast
the object to Part to get past the type. An A2A 0.3 DataPart has no
such field, and the extension specs put the MIME type in the part's
metadata. The Python a2a-sdk drops the unknown field when it parses the
message, so is_a2ui_part returns False for every client event these
shells send.

Move it to `metadata.mimeType`, as the Angular client and the Lit
shell's own middleware do, and drop the casts so the compiler checks
the part's shape. The Lit client's useStreaming part takes the same
change.
@github-project-automation github-project-automation Bot moved this to Todo in A2UI Oct 24, 2026
@github-actions github-actions Bot added the status: needs-triage auto-managed: https://github.com/a2ui-project/a2ui/blob/main/scripts/triage.mjs label Oct 24, 2026
@Varun-S10 Varun-S10 self-assigned this Oct 28, 2026
@Varun-S10

Copy link
Copy Markdown
Collaborator

Hi @retz8, Thank you for raising the pr to fix the issue. We have verified the pr and it does resolve the issue. I will escalate this to team to review. Thank you for your patience and understanding.
Hi @gspencergoog, Could you please take a look?

@Varun-S10 Varun-S10 added status: needs review and removed status: needs-triage auto-managed: https://github.com/a2ui-project/a2ui/blob/main/scripts/triage.mjs labels Oct 28, 2026
@gspencergoog

Copy link
Copy Markdown
Collaborator

/gemini review

@a2ui-project a2ui-project deleted a comment from gemini-code-assist Bot Oct 28, 2026

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates the structure of data parts in samples/client/lit/shell/client.ts and samples/client/react/shell/middleware/a2a.ts by nesting the mimeType property inside a new metadata object and removing the now unused Part type assertions and imports. As there are no review comments, I have no feedback to provide.

@github-actions github-actions Bot added the status: needs-triage auto-managed: https://github.com/a2ui-project/a2ui/blob/main/scripts/triage.mjs label Nov 20, 2026
@polina-c

polina-c commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

From triage bot, analysis:

For humans

TL;DR
Case: this external PR fixes a small bug in the Lit and React sample clients.
Suggestion: review it and assign gspencergoog.

Summary:
The Lit shell's A2UIClient and the React shell's A2A middleware put mimeType on the data part instead of its metadata, so the Python a2a-sdk drops it and agents do not recognize the client events as A2UI. The PR moves mimeType into metadata, and is linked to close #3601.

Targeted issues:
#3601

Suggestion:
Review it, and assign gspencergoog, who wrote 11 of the last 20 commits to both the Lit shell and the React shell. Varun-S10 verified the fix and asked gspencergoog to look on 2026-10-28. gspencergoog asked Gemini for a review, but has not reviewed the PR, so the review criteria apply. It meets the first and the third, and overlaps in part with open work:

  1. It is a minor bug fix: 9 added and 9 removed lines in 2 files. The shells have no tests for sending, and the description shows a manual check against an a2a-sdk agent. #3601 is P2, and is assigned to Varun-S10, not to the author.
  2. It overlaps in part with #4158 from gspencergoog, which adds metadata: {mimeType: A2UI_MIME_TYPE} to the Lit shell's client-event parts (lines 117 and 145) and keeps mimeType on the part. The draft #4325 has the same change. Neither touches the React shell or the useStreaming part, so this PR still adds a fix.
  3. The team can maintain it: the change is small, and it removes the as Part casts, so the compiler checks the shape of the parts.

As the author of #4158, gspencergoog can decide which PR lands the Lit change.

  1. Add labels: component: samples, type: bug
  2. Assign: gspencergoog
  3. Related items: feat(samples): add multi-turn ADK format playground sample and Lit shell config #4158, feat(samples): add decision_playground agent and Lit shell inspector #4325

To adjust the analysis and apply its suggestion, run in your a2ui checkout:

tools/internal/triage/triage_ui.sh https://github.com/a2ui-project/a2ui/pull/3602
For software
<a2ui>
root = TriageAnalysis(
  tldr="""Case: this external PR fixes a small bug in the Lit and React sample clients.
Suggestion: review it and assign `gspencergoog`.""",
  summary="""The Lit shell's `A2UIClient` and the React shell's A2A middleware put `mimeType` on the data part instead of its metadata, so the Python `a2a-sdk` drops it and agents do not recognize the client events as A2UI. The PR moves `mimeType` into `metadata`, and is linked to close [#3601](https://github.com/a2ui-project/a2ui/issues/3601).""",
  suggestion="""Review it, and assign `gspencergoog`, who wrote 11 of the last 20 commits to both the [Lit shell](https://github.com/a2ui-project/a2ui/commits/main/samples/client/lit/shell) and the [React shell](https://github.com/a2ui-project/a2ui/commits/main/samples/client/react/shell). `Varun-S10` [verified](https://github.com/a2ui-project/a2ui/pull/3602#issuecomment-6465354382) the fix and asked `gspencergoog` to look on 2026-10-28. `gspencergoog` [asked](https://github.com/a2ui-project/a2ui/pull/3602#issuecomment-6480782525) Gemini for a review, but has not reviewed the PR, so the review criteria apply. It meets the first and the third, and overlaps in part with open work:

1. It is a minor bug fix: 9 added and 9 removed lines in 2 files. The shells have no tests for sending, and the description shows a manual check against an `a2a-sdk` agent. [#3601](https://github.com/a2ui-project/a2ui/issues/3601) is P2, and is assigned to `Varun-S10`, not to the author.
2. It overlaps in part with [#4158](https://github.com/a2ui-project/a2ui/pull/4158) from `gspencergoog`, which adds `metadata: {mimeType: A2UI_MIME_TYPE}` to the Lit shell's client-event parts (lines [117](https://github.com/a2ui-project/a2ui/blob/5f381fbfe6df9611bf0c53d43af7d5ffe59da8b6/samples/client/lit/shell/client.ts#L117) and [145](https://github.com/a2ui-project/a2ui/blob/5f381fbfe6df9611bf0c53d43af7d5ffe59da8b6/samples/client/lit/shell/client.ts#L145)) and keeps `mimeType` on the part. The draft [#4325](https://github.com/a2ui-project/a2ui/pull/4325) has the same change. Neither touches the React shell or the `useStreaming` part, so this PR still adds a fix.
3. The team can maintain it: the change is small, and it removes the `as Part` casts, so the compiler checks the shape of the parts.

As the author of [#4158](https://github.com/a2ui-project/a2ui/pull/4158), `gspencergoog` can decide which PR lands the Lit change.""",
  added_labels=["component: samples", "type: bug"],
  new_assignees=["gspencergoog"],
  targeted_issues=[3601],
  related_items=[4158, 4325]
)
</a2ui>

This analysis is auto-created to help humans to triage this item. Please, do not treat it as a team decision.

🤖 Agent-generated

@polina-c

Copy link
Copy Markdown
Collaborator

Thanks for the fix. Assigning this PR to gspencergoog, whose #4158 makes a similar change to the Lit client, to decide on it.

@polina-c polina-c added component: samples Relevant to the agent or client samples status: assigned-for-triage issue/pr is assigned to a domain expert for further triage type: bug Something isn't working and removed status: needs-triage auto-managed: https://github.com/a2ui-project/a2ui/blob/main/scripts/triage.mjs labels Nov 20, 2026
@retz8

retz8 commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @polina-c! In case it helps: #4158 and the draft #4325 conflict with this PR in three places in the Lit shell's client.ts. They add metadata.mimeType to the two A2UI parts and keep mimeType on the part, and the useStreaming part keeps it on the part only. This PR puts it in metadata alone, as the e2e session from #4159 does. If #4158 lands first, I can trim this PR to what it leaves: the React shell's part and the Lit useStreaming part.

@gspencergoog gspencergoog left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change moves the A2A DataPart MIME type from a top-level mimeType field into metadata: {mimeType: ...} in samples/client/lit/shell/client.ts and samples/client/react/shell/middleware/a2a.ts, and removes the as Part casts that previously hid the schema mismatch from TypeScript. It also removes the now-unused Part import from samples/client/react/shell/middleware/a2a.ts while retaining Part in samples/client/lit/shell/client.ts where let parts: Part[] = [] uses it.

The updated literals match the @a2a-js/sdk DataPart type definition and downstream A2A consumers such as is_a2ui_part in python/a2ui_a2a. Local tsc/eslint checks were skipped in the ephemeral checkout because node_modules is not installed there.

🤖 Agent-generated

@gspencergoog
gspencergoog enabled auto-merge (squash) November 30, 2026 17:32

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

component: samples Relevant to the agent or client samples status: assigned-for-triage issue/pr is assigned to a domain expert for further triage status: needs review type: bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: The Lit and React sample clients put the A2UI MIME type on the part instead of its metadata

4 participants