Skip to content

feat: Add metadata support to Part types#658

Merged
kabir merged 2 commits intoa2aproject:mainfrom
ehsavoie:issue_649
Feb 17, 2026
Merged

feat: Add metadata support to Part types#658
kabir merged 2 commits intoa2aproject:mainfrom
ehsavoie:issue_649

Conversation

@ehsavoie
Copy link
Collaborator

Add optional metadata field to TextPart, FilePart, and DataPart records to support additional contextual information for message and artifact content parts as specified in the A2A protocol v1.0.

Changes:

  • Add metadata parameter to Part constructors (TextPart, FilePart, DataPart)
  • Update PartMapper to convert metadata between domain and gRPC proto
  • Update JsonUtil PartTypeAdapter to serialize/deserialize metadata

Fixes #649 🦕

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @ehsavoie, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the A2A protocol implementation by adding support for an optional metadata field to TextPart, FilePart, and DataPart types. This change allows for richer contextual information to be associated with message and artifact content parts. The modifications span across domain object definitions, JSON serialization/deserialization logic, and gRPC mapping to ensure seamless integration and proper handling of this new field throughout the system.

Highlights

  • Metadata Support for Part Types: Introduced an optional metadata field to TextPart, FilePart, and DataPart records, allowing for additional contextual information as specified in the A2A protocol v1.0.
  • Serialization and Deserialization: Updated JsonUtil's PartTypeAdapter to correctly serialize and deserialize the new metadata field for all affected Part types, ensuring proper JSON representation.
  • gRPC Mapping: Modified PartMapper to handle the conversion of the metadata field between the domain objects (TextPart, FilePart, DataPart) and their corresponding gRPC protocol buffer representations.
  • Constructor and Builder Updates: Adjusted the constructors of TextPart, FilePart, and DataPart to accept the new optional metadata parameter. The DataPart.Builder was also updated to include a method for setting metadata.
Changelog
  • jsonrpc-common/src/main/java/io/a2a/jsonrpc/common/json/JsonUtil.java
    • Imported java.util.Map and com.google.gson.reflect.TypeToken for metadata handling.
    • Modified PartTypeAdapter to serialize the metadata field for TextPart, FilePart, and DataPart.
    • Modified PartTypeAdapter to deserialize the metadata field for TextPart, FilePart, and DataPart.
    • Updated PartTypeAdapter's read method to allow metadata as an optional key in Part objects, adjusting key count validation.
  • jsonrpc-common/src/test/java/io/a2a/jsonrpc/common/json/StreamingEventKindSerializationTest.java
    • Updated TextPart instantiations to include null for the new metadata parameter in test cases.
  • jsonrpc-common/src/test/java/io/a2a/jsonrpc/common/json/TaskSerializationTest.java
    • Updated TextPart, FilePart, and DataPart instantiations to include null for the new metadata parameter in various test cases.
  • pom.xml
    • Added version.testcontainers property to manage Testcontainers dependency version.
    • Added testcontainers-bom dependency with import scope to the dependency management section.
  • spec-grpc/src/main/java/io/a2a/grpc/mapper/PartMapper.java
    • Modified toProto method to map the metadata field from TextPart, FilePart, and DataPart to their gRPC protocol buffer representations.
    • Modified fromProto method to map the metadata field from gRPC protocol buffer representations back to TextPart, FilePart, and DataPart.
  • spec-grpc/src/test/java/io/a2a/grpc/mapper/StreamResponseMapperTest.java
    • Updated TextPart instantiations to include null for the new metadata parameter in test cases.
  • spec-grpc/src/test/java/io/a2a/grpc/utils/ToProtoTest.java
    • Updated TextPart instantiations to include null for the new metadata parameter in test cases.
  • spec/src/main/java/io/a2a/spec/DataPart.java
    • Imported java.util.HashMap and java.util.Map.
    • Added @Nullable Map<String, Object> metadata to the DataPart record constructor.
    • Updated the build method in DataPart.Builder to include the metadata parameter.
    • Added a metadata field and a metadata setter method to DataPart.Builder.
  • spec/src/main/java/io/a2a/spec/FilePart.java
    • Imported java.util.Map and org.jspecify.annotations.Nullable.
    • Added @Nullable Map<String, Object> metadata to the FilePart record constructor.
  • spec/src/main/java/io/a2a/spec/Message.java
    • Reformatted constructor parameters for improved readability without functional changes.
  • spec/src/main/java/io/a2a/spec/TextPart.java
    • Imported java.util.Map and org.jspecify.annotations.Nullable.
    • Added @Nullable Map<String, Object> metadata to the TextPart record constructor.
Activity
  • No human activity (comments, reviews) has been recorded on this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

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 successfully adds support for an optional metadata field to TextPart, FilePart, and DataPart, which is a great enhancement for providing more context. The changes correctly update the domain objects, JSON serializers/deserializers, and gRPC mappers.

My review includes a few suggestions to improve the implementation:

  • A critical fix for invalid characters in pom.xml.
  • A fix for a potential NullPointerException in the DataPart builder.
  • Suggestions for refactoring to reduce code duplication.
  • A recommendation to add tests for the new metadata functionality to ensure correctness.

I also noticed that a dependency for testcontainers was added in pom.xml. This seems unrelated to the main goal of this PR. It's generally a good practice to keep pull requests focused on a single feature or fix to make them easier to review and merge.

@ehsavoie ehsavoie force-pushed the issue_649 branch 2 times, most recently from 870188f to 88146ca Compare February 16, 2026 16:41
@ehsavoie ehsavoie requested review from jmesnil and kabir February 16, 2026 18:08
Copy link
Collaborator

@kabir kabir left a comment

Choose a reason for hiding this comment

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

Needs a rebase

@ehsavoie ehsavoie force-pushed the issue_649 branch 2 times, most recently from 447c543 to f8b4100 Compare February 17, 2026 11:43
Add optional metadata field to TextPart, FilePart, and DataPart records
to support additional contextual information for message and artifact
content parts as specified in the A2A protocol v1.0.

Changes:
  - Add metadata parameter to Part constructors (TextPart, FilePart, DataPart)
  - Update PartMapper to convert metadata between domain and gRPC proto
  - Update JsonUtil PartTypeAdapter to serialize/deserialize metadata

Signed-off-by: Emmanuel Hugonnet <ehugonne@redhat.com>
@kabir kabir merged commit 760b6a8 into a2aproject:main Feb 17, 2026
10 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat]: Support adding metadata to Part in 1.0.0.Alpha (regression from 0.3.x)

3 participants