Skip to content

Conversation

@a2a-bot
Copy link
Collaborator

@a2a-bot a2a-bot commented Sep 2, 2025

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.

Summary of Changes

Hello @a2a-bot, 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 updates the A2A specification by introducing a new metadata field to the Part message within the protobuf definition. This enhancement provides a flexible mechanism to embed arbitrary structured data directly into message parts, significantly improving the extensibility and information richness of A2A messages. The corresponding Python generated files have been updated to incorporate these changes.

Highlights

  • Protobuf Part message enhancement: Added a metadata field of type google.protobuf.Struct to the Part message in the A2A protobuf definition. This allows for associating arbitrary structured data with individual message parts.
  • Generated files update: Regenerated the Python protobuf files (a2a_pb2.py and a2a_pb2.pyi) to reflect the updated specification, ensuring type safety and correct serialization.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

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 issue 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 updates the protobuf specification to add a metadata field to the Part message. While the generated Python files (a2a_pb2.py and a2a_pb2.pyi) correctly reflect this change, a critical piece of logic is missing. The conversion utility in src/a2a/utils/proto_utils.py has not been updated to handle this new field, which will cause the metadata to be lost during serialization and deserialization. This must be addressed before merging.

@holtskinner holtskinner changed the title Update to specification from b3b266d127dde3d1000ec103b252d1de81289e83 fix(proto): Adds metadata field to A2A DataPart proto Sep 2, 2025
@holtskinner
Copy link
Member

@gemini-code-assist review

@holtskinner holtskinner merged commit 6d0ef59 into main Sep 2, 2025
8 checks passed
@holtskinner holtskinner deleted the auto-update-a2a-types-b3b266d127dde3d1000ec103b252d1de81289e83 branch September 2, 2025 17:11
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 adds a metadata field to the Part protobuf message, allowing for metadata to be associated with any type of message part. The changes are correctly reflected in the generated protobuf files. The proto_utils.py file has been updated to handle the new field during type conversions.

My review focuses on improving the maintainability and correctness of the conversion logic in proto_utils.py. I've suggested refactoring the ToProto.part and FromProto.part methods to reduce code duplication. More importantly, I've identified a potential bug in FromProto.part where the check for metadata presence is incorrect, and I've provided a suggestion to fix it while also making the code cleaner.

Comment on lines 511 to 539
def part(cls, part: a2a_pb2.Part) -> types.Part:
if part.HasField('text'):
return types.Part(root=types.TextPart(text=part.text))
return types.Part(
root=types.TextPart(
text=part.text,
metadata=cls.metadata(part.metadata)
if part.metadata
else None,
),
)
if part.HasField('file'):
return types.Part(root=types.FilePart(file=cls.file(part.file)))
return types.Part(
root=types.FilePart(
file=cls.file(part.file),
metadata=cls.metadata(part.metadata)
if part.metadata
else None,
),
)
if part.HasField('data'):
return types.Part(root=types.DataPart(data=cls.data(part.data)))
return types.Part(
root=types.DataPart(
data=cls.data(part.data),
metadata=cls.metadata(part.metadata)
if part.metadata
else None,
),
)
raise ValueError(f'Unsupported part type: {part}')
Copy link
Contributor

Choose a reason for hiding this comment

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

high

The logic for handling metadata is repeated in each branch, and the condition if part.metadata is incorrect because a protobuf message object is always truthy. This means the else None branch is unreachable, and empty metadata will be converted to an empty dictionary {} instead of None. This can be a subtle bug if downstream code expects None.

I suggest refactoring to extract the common metadata handling logic, which also fixes the bug and makes the code more readable and maintainable.

    def part(cls, part: a2a_pb2.Part) -> types.Part:
        metadata = cls.metadata(part.metadata) if part.metadata.fields else None
        if part.HasField('text'):
            return types.Part(
                root=types.TextPart(
                    text=part.text,
                    metadata=metadata,
                ),
            )
        if part.HasField('file'):
            return types.Part(
                root=types.FilePart(
                    file=cls.file(part.file),
                    metadata=metadata,
                ),
            )
        if part.HasField('data'):
            return types.Part(
                root=types.DataPart(
                    data=cls.data(part.data),
                    metadata=metadata,
                ),
            )
        raise ValueError(f'Unsupported part type: {part}')

Comment on lines 74 to 89
def part(cls, part: types.Part) -> a2a_pb2.Part:
if isinstance(part.root, types.TextPart):
return a2a_pb2.Part(text=part.root.text)
return a2a_pb2.Part(
text=part.root.text, metadata=cls.metadata(part.root.metadata)
)
if isinstance(part.root, types.FilePart):
return a2a_pb2.Part(file=cls.file(part.root.file))
return a2a_pb2.Part(
file=cls.file(part.root.file),
metadata=cls.metadata(part.root.metadata),
)
if isinstance(part.root, types.DataPart):
return a2a_pb2.Part(data=cls.data(part.root.data))
return a2a_pb2.Part(
data=cls.data(part.root.data),
metadata=cls.metadata(part.root.metadata),
)
raise ValueError(f'Unsupported part type: {part.root}')
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The logic for creating the a2a_pb2.Part is repeated across the different if statements. You can refactor this to be more DRY (Don't Repeat Yourself) by preparing the arguments for a2a_pb2.Part and calling it only once at the end. This improves maintainability.

    def part(cls, part: types.Part) -> a2a_pb2.Part:
        kwargs = {"metadata": cls.metadata(part.root.metadata)}
        if isinstance(part.root, types.TextPart):
            kwargs["text"] = part.root.text
        elif isinstance(part.root, types.FilePart):
            kwargs["file"] = cls.file(part.root.file)
        elif isinstance(part.root, types.DataPart):
            kwargs["data"] = cls.data(part.root.data)
        else:
            raise ValueError(f'Unsupported part type: {part.root}')
        return a2a_pb2.Part(**kwargs)

holtskinner pushed a commit that referenced this pull request Sep 8, 2025
🤖 I have created a release *beep* *boop*
---


##
[0.3.5](v0.3.4...v0.3.5)
(2025-09-08)


### Bug Fixes

* Prevent client disconnect from stopping task execution
([#440](#440))
([58b4c81](58b4c81)),
closes [#296](#296)
* **proto:** Adds metadata field to A2A DataPart proto
([#455](#455))
([6d0ef59](6d0ef59))


### Documentation

* add example docs for `[@Validate](https://github.com/validate)` and
`[@Validate](https://github.com/validate)_async_generator`
([#422](#422))
([18289eb](18289eb))
* Restructure README
([9758f78](9758f78))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants