Skip to content

Conversation

@zbirkenbuel
Copy link

Python and Go implementations of ADK both copy function call and response properties by copying the entire struct automatically. Java does this a property at a time and so was missing the "id" property of the ADK event. Providing these allows downstream agents to properly associate multiple tool calls and responses to the same tool name.

Updated EventConverterTest to verify the new field and also verified function name in the response object.

…ls to a2a

Python and Go implementations of ADK both copy function call and response
properties by copying the entire struct automatically. Java does this a property
at a time and so was missing the "id" property of the ADK event. Providing these
allows downstream agents to properly associate multiple tool calls and responses
to the same tool name.
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @zbirkenbuel, 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 resolves an inconsistency in the Java ADK's handling of function call and response properties by ensuring the critical 'id' property is properly translated. This change is vital for downstream agents to accurately associate multiple tool calls and responses, thereby enhancing the reliability and consistency of the ADK's cross-language functionality.

Highlights

  • Function Call and Response ID Translation: The Java ADK implementation now correctly translates the 'id' property for both function calls and function responses when converting to a2a, aligning its behavior with Python and Go implementations.
  • PartConverter Update: The PartConverter class has been modified to extract and include the functionId property for both FunctionCall and FunctionResponse objects during the conversion process.
  • Enhanced Test Coverage: Unit tests in EventConverterTest were updated to include and verify the id property in function call and response parts, ensuring its correct preservation and translation.
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 identifies and addresses a gap in the Java ADK's property conversion for function calls and responses by adding the id field. However, the implementation is incomplete as it only handles the A2A-to-GenAI conversion direction. The reverse (GenAI-to-A2A) is missing. I've also pointed out a potential issue with null handling for the ID and a small error in the updated test. Addressing these points will make the implementation robust and complete.

Comment on lines 134 to 140
String functionName = String.valueOf(data.getOrDefault("name", ""));
String functionId = String.valueOf(data.getOrDefault("id", ""));
Map<String, Object> args = coerceToMap(data.get("args"));
return Optional.of(
com.google.genai.types.Part.builder()
.functionCall(FunctionCall.builder().name(functionName).args(args).build())
.functionCall(FunctionCall.builder().name(functionName).id(functionId).args(args).build())
.build());
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

This change is a good step, but there are two issues to address for the function call conversion:

  1. Incomplete Conversion: The reverse conversion from a GenAI FunctionCall to an A2A DataPart is missing. The createDataPartFromFunctionCall method should be updated to also handle the id property, otherwise it will be lost. This will also cause the new tests to fail.
  2. Null Handling: The current approach to get the id can result in bugs. If data contains ("id", null), functionId will become the string "null".

Here is a suggested improvement for the null handling. Please also address the missing reverse conversion.

      String functionName = String.valueOf(data.getOrDefault("name", ""));
      Object idObj = data.get("id");
      String functionId = (idObj == null) ? null : String.valueOf(idObj);
      Map<String, Object> args = coerceToMap(data.get("args"));
      return Optional.of(
          com.google.genai.types.Part.builder()
              .functionCall(FunctionCall.builder().name(functionName).id(functionId).args(args).build())
              .build());

Comment on lines 145 to 152
String functionName = String.valueOf(data.getOrDefault("name", ""));
String functionId = String.valueOf(data.getOrDefault("id", ""));
Map<String, Object> response = coerceToMap(data.get("response"));
return Optional.of(
com.google.genai.types.Part.builder()
.functionResponse(
FunctionResponse.builder().name(functionName).response(response).build())
FunctionResponse.builder().name(functionName).id(functionId).response(response).build())
.build());
Copy link
Contributor

Choose a reason for hiding this comment

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

critical

Similar to the function call, there are two issues to address for the function response conversion:

  1. Incomplete Conversion: The reverse conversion from a GenAI FunctionResponse to an A2A DataPart is missing. The createDataPartFromFunctionResponse method should be updated to also handle the id property.
  2. Null Handling: The id retrieval here can lead to a "null" string ID if the value in the map is null.

Here is a suggested improvement for the null handling. Please also address the missing reverse conversion.

      String functionName = String.valueOf(data.getOrDefault("name", ""));
      Object idObj = data.get("id");
      String functionId = (idObj == null) ? null : String.valueOf(idObj);
      Map<String, Object> response = coerceToMap(data.get("response"));
      return Optional.of(
          com.google.genai.types.Part.builder()
              .functionResponse(
                  FunctionResponse.builder().name(functionName).id(functionId).response(response).build())
              .build());

…ls to a2a

Python and Go implementations of ADK both copy function call and response
properties by copying the entire struct automatically. Java does this a property
at a time and so was missing the "id" property of the ADK event. Providing these
allows downstream agents to properly associate multiple tool calls and responses
to the same tool name.
…ls to a2a

Python and Go implementations of ADK both copy function call and response
properties by copying the entire struct automatically. Java does this a property
at a time and so was missing the "id" property of the ADK event. Providing these
allows downstream agents to properly associate multiple tool calls and responses
to the same tool name.
@zbirkenbuel zbirkenbuel deleted the function_call_id branch December 11, 2025 01:24
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.

1 participant