Expand description
A2A Message and Part value objects.
§What these are
A Message is the unit of conversation between
an A2A client and an A2A agent. It has a role
(the user or the agent), a list of Parts
(the content), and an optional metadata map.
A Part is the unit of content within a
message. A2A defines three part kinds:
TextPart— a UTF-8 string.FilePart— a file (named, MIME-typed, with either an inline base64 payload or a URI).DataPart— a structured JSON value.
The wire form of a Part is the proto’s
oneof content: the JSON object has exactly
one of text, file, or data as a top-level
field. The optional metadata field rides
alongside whichever content field is present.
§Why an untagged enum, not a tagged one
A tagged enum ({ "kind": "text", "text": "..." })
is unambiguous but adds a key the spec does
not name. An untagged enum
({ "text": "..." } for text, { "file": {...} }
for file, { "data": {...} } for data) is
what the spec writes, and serde’s untagged
deserialisation is the matching Rust shape.
The trade-off is that a malformed part with
both text and file deserialises as the
first variant (text) and silently drops the
file field; the alternative is
#[serde(deny_unknown_fields)] on each
variant, which would reject the malformed
case as a deserialisation error. The spec
allows the lenient shape (a part with at
most one of text/file/data), so the
lenient deserialisation is the right wire
match.
§Why metadata is on each part variant, not on
the enum
The proto’s Part message is a wrapper around
oneof content plus a metadata field. The
JSON form flattens this — a Part is
{ <content-field>, "metadata": {...}? },
and the metadata field rides alongside
whichever content field is present. The Rust
shape that round-trips with the wire form
is one struct per variant, each with its own
metadata field; the enum just dispatches
on which of text/file/data is present.
Structs§
- Data
Part - A structured data part. Wire form:
{ "data": {...}, "metadata"?: {...} }. - File
Content - The content of a
FilePart. Wire form:{ "name"?: "...", "mimeType"?: "...", "bytes"?: "base64...", "uri"?: "..." }. - File
Part - A file part. Wire form:
{ "file": {...}, "metadata"?: {...} }. - Message
- A message exchanged between a client and an agent.
- Text
Part - A text part. Wire form:
{ "text": "...", "metadata"?: {...} }.
Enums§
- Message
Role - The author of a
Message. - Part
- A unit of content within a
Message.