Skip to content

feat: Add message creation methods with contextId and taskId support#322

Merged
fjuma merged 3 commits intoa2aproject:mainfrom
Asymtode712:msgfeat
Oct 7, 2025
Merged

feat: Add message creation methods with contextId and taskId support#322
fjuma merged 3 commits intoa2aproject:mainfrom
Asymtode712:msgfeat

Conversation

@Asymtode712
Copy link
Contributor

PR Description

  • Added new message creation methods to A2A.java (createUserMessage, createAgentMessage, createMessage)

  • Implemented support for configuring contextId, taskId, parts, metadata, and referenceTaskIds

  • Added comprehensive test cases in A2ATest.java to verify functionality

  • Methods follow similar pattern to the Python implementation for consistency across SDKs

  • Follow the CONTRIBUTING Guide.

  • Ensure the tests pass

Fixes #302 🦕

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @Asymtode712, 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 message creation capabilities within the A2A Java SDK. It introduces new, more configurable methods for creating user and agent messages, allowing developers to specify additional attributes like context and task identifiers, custom message parts, and metadata. This update aims to provide a more robust and consistent API experience, mirroring the functionality available in the Python SDK, and is backed by thorough unit tests to ensure reliability.

Highlights

  • New Message Creation Methods: Introduced createUserMessage, createAgentMessage, and a general createMessage method in A2A.java to offer more flexible message construction.
  • Enhanced Message Configuration: The new methods support configuring contextId, taskId, custom parts, metadata, and referenceTaskIds for messages.
  • Consistency with Python SDK: The new message creation patterns align with the existing Python implementation, ensuring consistency across SDKs.
  • Comprehensive Test Coverage: Added a new test file A2ATest.java with extensive test cases to verify the functionality of all new message creation methods and their various configuration options.
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.

@Asymtode712
Copy link
Contributor Author

@kabir @fjuma please review this PR

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 introduces new factory methods in A2A.java for creating Message objects with extended options like contextId, taskId, and custom parts. The changes are well-structured and follow the existing pattern of the class. Comprehensive unit tests have been added in A2ATest.java to cover the new functionality. My review includes a couple of suggestions for code simplification and improving documentation clarity in the new createMessage method.

Copy link
Collaborator

@fjuma fjuma left a comment

Choose a reason for hiding this comment

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

@Asymtode712 Thanks for the PR! I've added some comments on it. Feel free to let us know if you have any questions.

@Asymtode712
Copy link
Contributor Author

@fjuma done with the changes, pls review

Copy link
Collaborator

@fjuma fjuma left a comment

Choose a reason for hiding this comment

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

Thanks @Asymtode712!

@fjuma fjuma merged commit 71c56ea into a2aproject:main Oct 7, 2025
7 checks passed
kabir pushed a commit to kabir/a2a-java that referenced this pull request Dec 23, 2025
…2aproject#322)

## PR Description

- Added new message creation methods to A2A.java (createUserMessage,
createAgentMessage, createMessage)
- Implemented support for configuring contextId, taskId, parts,
metadata, and referenceTaskIds
- Added comprehensive test cases in A2ATest.java to verify functionality
- Methods follow similar pattern to the Python implementation for
consistency across SDKs


- [x] Follow the [`CONTRIBUTING` Guide](../CONTRIBUTING.md).
- [x] Ensure the tests pass

Fixes a2aproject#302  🦕
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.

[Feat]: Add additional methods for creating and handling messages to A2A.java

2 participants