Skip to content

Conversation

@martimfasantos
Copy link
Contributor

@martimfasantos martimfasantos commented Oct 21, 2025

Description

This pull request refactors utility functions for handling Part objects by moving them from src/a2a/utils/message.py to a new dedicated module src/a2a/utils/parts.py. It also introduces a new helper function for extracting text from Artifacts and updates imports and exports to reflect these changes. The goal is to improve code organization and clarity by grouping similar functionality.

Refactoring and organization:

  • Moved the functions get_text_parts, get_data_parts, and get_file_parts from src/a2a/utils/message.py into a new module src/a2a/utils/parts.py, providing better separation of concerns for part-handling utilities. [1] [2]
  • Updated imports in src/a2a/utils/__init__.py to re-export these part-handling functions from the new parts module, and removed their previous import from the message module. [1] [2] [3]

New functionality:

  • Added the new function get_artifact_text to src/a2a/utils/artifact.py for extracting and joining all text content from an artifact's parts, using the refactored get_text_parts. [1] [2] [3] [4]

These changes improve maintainability by clearly separating message-related and part-related utilities, and by introducing a helper for artifact text extraction.


BEGIN_COMMIT_OVERRIDE
refactor(utils): move part helpers to their own file
feat: add get_artifact_text() helper method

Release-As: 0.3.10
END_COMMIT_OVERRIDE

@martimfasantos martimfasantos requested a review from a team as a code owner October 21, 2025 09:11
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @martimfasantos, 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 significantly enhances the codebase's maintainability and clarity by reorganizing utility functions. It isolates "Part" object handling into its own module, "src/a2a/utils/parts.py", and introduces a new function for extracting text from "Artifacts". These changes streamline the codebase, making it easier to understand and manage related functionalities.

Highlights

  • Code Refactoring for Part Handling: Utility functions for handling "Part" objects ("get_text_parts", "get_data_parts", "get_file_parts") have been moved from "src/a2a/utils/message.py" to a new dedicated module "src/a2a/utils/parts.py" to improve code organization and separation of concerns.
  • New Artifact Text Extraction: A new helper function, "get_artifact_text", has been introduced in "src/a2a/utils/artifact.py" to efficiently extract and join all text content from an "Artifact"'s parts.
  • Module Import/Export Updates: The "src/a2a/utils/init.py" file has been updated to reflect the refactoring, re-exporting the part-handling functions from the new "parts" module and importing the new "get_artifact_text" function.
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 does a good job of refactoring the part-related utility functions into a new parts.py module, which improves code organization. The addition of get_artifact_text is also a useful helper.

However, I've found a critical issue with circular dependencies introduced by the new imports in artifact.py and message.py. Both modules now import from the a2a.utils package, which itself imports from them, creating a cycle. My review comments provide suggestions to fix this by preventing runtime import errors.

Additionally, there are a couple of points regarding testing:

  • The new function get_artifact_text is missing unit tests. I've added a suggestion to include them.
  • The existing tests for the moved functions (get_text_parts, etc.) in tests/utils/test_message.py will likely fail because the functions have been moved. These tests should be updated to import from the new location (a2a.utils.parts or a2a.utils) and ideally moved to a new tests/utils/test_parts.py file to align with the new code structure. It seems the test files were not part of this PR, so you'll need to add them.

@holtskinner holtskinner merged commit 9155888 into a2aproject:main Oct 21, 2025
7 checks passed
@martimfasantos martimfasantos deleted the task-add-artifact-utils branch October 21, 2025 21:35
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.

3 participants