-
Notifications
You must be signed in to change notification settings - Fork 261
Ensure all property types are translated when converting function calls to a2a #656
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…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.
Summary of ChangesHello @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
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this 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.
| 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()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is a good step, but there are two issues to address for the function call conversion:
- Incomplete Conversion: The reverse conversion from a GenAI
FunctionCallto an A2ADataPartis missing. ThecreateDataPartFromFunctionCallmethod should be updated to also handle theidproperty, otherwise it will be lost. This will also cause the new tests to fail. - Null Handling: The current approach to get the
idcan result in bugs. Ifdatacontains("id", null),functionIdwill 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());| 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()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the function call, there are two issues to address for the function response conversion:
- Incomplete Conversion: The reverse conversion from a GenAI
FunctionResponseto an A2ADataPartis missing. ThecreateDataPartFromFunctionResponsemethod should be updated to also handle theidproperty. - Null Handling: The
idretrieval here can lead to a"null"string ID if the value in the map isnull.
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.
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.