-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Description
When A2A agents send TextPart with metadata (e.g., textContentType: "Markdown"), Part.ToAIContent() correctly stores the metadata in TextContent.AdditionalProperties. However, AsAGUIEventStreamAsync creates TextMessageStartEvent and TextMessageContentEvent with only MessageId, Role, and Delta — AdditionalProperties is silently dropped.
This means the AG-UI client has no way to know how to render the text (Markdown, code, plain text, etc.) from the standard event stream.
The AG-UI protocol supports this
The @ag-ui/core Zod schemas use "passthrough" mode, meaning extra properties on any event are preserved and valid. Adding a metadata field to TEXT_MESSAGE_START / TEXT_MESSAGE_CONTENT events is fully compatible with the AG-UI protocol specification.
Reproduction
-
Create an A2A agent that returns text with metadata:
{ "parts": [{ "type": "text", "text": "Hello world", "metadata": { "textContentType": "Markdown" } }] } -
Use
MapAGUIto expose the orchestrator as an AG-UI endpoint. -
Observe the SSE output:
data: {"type":"TEXT_MESSAGE_START","messageId":"msg-1","role":"assistant"}The
textContentTypemetadata is missing.
Expected behavior
AdditionalProperties from TextContent should be forwarded as extra properties on the SSE event JSON, since the AG-UI protocol's passthrough schemas allow it:
data: {"type":"TEXT_MESSAGE_START","messageId":"msg-1","role":"assistant","textContentType":"Markdown"}
Or alternatively, as a nested metadata field:
data: {"type":"TEXT_MESSAGE_START","messageId":"msg-1","role":"assistant","metadata":{"textContentType":"Markdown"}}
Root cause
In ChatResponseUpdateAGUIExtensions.AsAGUIEventStreamAsync, the TextMessageStartEvent is constructed with only two properties:
new TextMessageStartEvent
{
MessageId = chatResponse.MessageId,
Role = chatResponse.Role.Value
};TextContent.AdditionalProperties from the ChatResponseUpdate.Contents is never read or forwarded.
Similarly, TextMessageContentEvent only copies MessageId and Delta:
new TextMessageContentEvent
{
MessageId = chatResponse.MessageId,
Delta = textContent.Text
};Code Sample
Error Messages / Stack Traces
Package Versions
Microsoft.Agents.AI.Hosting.AGUI.AspNetCore: 1.0.0-preview.260121.1 and 1.0.0-preview.260311.1
.NET Version
No response
Additional Context
No response