Skip to content

Conversation

@kabir
Copy link
Collaborator

@kabir kabir commented Dec 17, 2025

Fixes #544

@kabir kabir changed the title feat!: Remove kind discrimintator as per the 1.0 specification feat!: Remove kind discriminator as per the 1.0 specification Dec 17, 2025
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @kabir, 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 implements a significant update to the JSON serialization and deserialization logic for core data structures like Part and StreamingEventKind, bringing them into full compliance with the A2A Protocol 1.0 specification. The change primarily involves transitioning from an explicit "kind" field for type discrimination to a more modern member name discriminator pattern. This ensures that JSON payloads are structured according to the latest protocol, impacting how polymorphic types are represented and processed throughout the system.

Highlights

  • Protocol Alignment: The JSON serialization and deserialization mechanisms for Part and StreamingEventKind objects have been updated to align with the A2A Protocol 1.0 specification.
  • Discriminator Change: The explicit "kind" field previously used for type discrimination in JSON payloads has been removed. Instead, a member name discriminator approach is now used, where the JSON field name itself (e.g., "text", "file", "task", "message") indicates the type of the nested object.
  • Serialization Logic Refinement: The JsonUtil class's PartTypeAdapter and StreamingEventKindTypeAdapter have been refactored to implement the new member name discrimination for both writing and reading JSON. This includes handling both wrapped and unwrapped event formats for StreamingEventKind.
  • Codebase Modernization: The Part.Kind enum and its associated TypeAdapter have been removed, simplifying the codebase. All instances of type checking using getKind() have been replaced with instanceof pattern matching, which is more idiomatic in modern Java.
  • Test Suite Updates: Numerous test cases across the client, extras, server-common, and spec modules have been updated to reflect the new JSON structure and the instanceof type checking, ensuring compatibility and correctness with the protocol changes.
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 correctly implements the removal of the kind discriminator from JSON serialization, aligning with the 1.0 specification. The changes are consistently applied across the codebase, including specification interfaces, serialization logic, and test suites. The use of wrapper objects for polymorphic deserialization is well-executed.

I found one significant inconsistency in the new serialization format for DataPart compared to FilePart, which results in an extra, unnecessary wrapper in the JSON. I've provided detailed comments and suggestions to correct this, which will make the serialization format more consistent and intuitive. Other than that, the changes are excellent.

@kabir
Copy link
Collaborator Author

kabir commented Dec 17, 2025

/gemini review

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 is a significant but well-executed refactoring to align with the 1.0 specification by removing the kind discriminator field from data models. The changes consistently replace the kind field with member name discriminators for polymorphic JSON serialization across DTOs, JSON type adapters, and tests. My review found the implementation to be largely correct, but I've identified two opportunities in JsonUtil.java to make the parsing logic stricter. These suggestions aim to better enforce the "oneof" semantics of the new protocol, which will improve robustness against malformed JSON and prevent potential ambiguity.

@ehsavoie ehsavoie merged commit bed152d into a2aproject:main Dec 18, 2025
11 checks passed
@kabir kabir deleted the remove-kind branch December 18, 2025 13:29
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]: Remove 'kind' field discriminator

2 participants