Skip to content

Conversation

@fsonntag
Copy link

@fsonntag fsonntag commented Jan 9, 2026

Fix A2A metadata key prefix for cross-language compatibility

Problem

When evaluating Java agents from Python via A2A protocol, tool calls were not being tracked because metadata keys didn't match Python's expectations.

Root cause: Python expects metadata keys with adk_ prefix (e.g., adk_type), but Java was sending unprefixed keys (e.g., type).

Solution

Added ADK_METADATA_KEY_PREFIX = "adk_" constant and prefixed metadata keys to align with Python's convention:

  • A2A_DATA_PART_METADATA_TYPE_KEY"adk_type"
  • A2A_DATA_PART_METADATA_IS_LONG_RUNNING_KEY"adk_is_long_running"

Metadata values (like "function_call") remain unprefixed as expected.

Changes

File: a2a/src/main/java/com/google/adk/a2a/converters/PartConverter.java

  • Added ADK_METADATA_KEY_PREFIX constant at line 33
  • Updated metadata key constants at lines 36-38 to use prefix
  • Value constants (lines 39-43) correctly remain unprefixed

Python Reference

Python's implementation using _get_adk_metadata_key() helper:
https://github.com/google/adk/blob/main/adk-python/src/google/adk/a2a/converters/part_converter.py#L36-L41

Python adds prefix when reading metadata:
https://github.com/google/adk/blob/main/adk-python/src/google/adk/a2a/converters/part_converter.py#L93-L98

Testing

Verified with cross-language A2A evaluation showing tool calls now properly tracked.

@google-cla
Copy link

google-cla bot commented Jan 9, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @fsonntag, 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 addresses a critical cross-language compatibility issue within the A2A protocol, specifically when Java agents are evaluated by Python. By standardizing the metadata key prefixes used by Java to match Python's expectations, it ensures that tool calls are correctly tracked across the two languages, thereby improving the robustness and interoperability of the A2A system.

Highlights

  • Cross-language A2A compatibility fix: Resolves an issue where Java agents evaluated from Python failed to track tool calls due to a mismatch in A2A metadata key prefixes.
  • Metadata key prefixing: Introduces an "adk_" prefix for specific A2A metadata keys ("type" and "is_long_running") in Java to align with Python's expected format.
  • New constant introduced: A new constant, "ADK_METADATA_KEY_PREFIX", was added to centralize the "adk_" prefix for metadata keys.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

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 addresses a cross-language compatibility issue between the Java and Python A2A implementations by adding the expected adk_ prefix to metadata keys. The use of a dedicated constant for the prefix is a good choice for maintainability. The change is focused, well-explained, and effectively resolves the issue. I have one suggestion to improve the clarity of a new comment.

@fsonntag fsonntag force-pushed the add-adk-metadata-prefix branch from 36802a3 to 50ccfcd Compare January 9, 2026 09:05
@fsonntag fsonntag force-pushed the add-adk-metadata-prefix branch from 50ccfcd to 034ada1 Compare January 9, 2026 09:09
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