Skip to content

Conversation

@hoonji
Copy link
Contributor

@hoonji hoonji commented Nov 20, 2025

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

Solution:
Adds Event.actions to A2A event metadata during ADK -> A2A event conversion (to allow A2A event consumers to access important info like state_delta, artifact delta, etc)

Testing Plan

pytest ./tests/unittests passes

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @hoonji, 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 enhances the ADK to A2A event conversion by incorporating the Event.actions attribute into the A2A event metadata. This ensures that crucial action-related data, like state and artifact deltas, is consistently available to downstream A2A event consumers, thereby enriching the event data and supporting more comprehensive processing.

Highlights

  • ADK Event Actions: The pull request adds Event.actions to the A2A event metadata during the ADK to A2A event conversion process.
  • Data Accessibility: This change enables A2A event consumers to access important information such as state_delta and artifact_delta from the converted events.
  • Unit Test Updates: Corresponding unit tests have been updated to reflect the inclusion of actions in the event metadata and to properly mock its behavior.
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.

@adk-bot adk-bot added the core [Component] This issue is related to the core interface and implementation label Nov 20, 2025
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 adds the Event.actions field to the A2A event metadata, ensuring that action-related information is passed along during event conversion. The changes are straightforward and include corresponding unit tests to verify the new behavior.

My review includes two main points for consideration. First, I've noted a pre-existing inconsistency with type hints related to metadata serialization, which this PR's test changes make more apparent. Second, I've pointed out that due to the current data model, empty EventActions objects will always be included in the metadata, which is inefficient. I've suggested that these be addressed in follow-up work to improve code clarity and efficiency.

("custom_metadata", event.custom_metadata),
("usage_metadata", event.usage_metadata),
("error_code", event.error_code),
("actions", event.actions),
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The actions field on an Event object is initialized with default_factory=EventActions, so event.actions will never be None. As a result, it will always be serialized and included in the metadata, even if it's an empty object representing no actions. This adds unnecessary data to every A2A event.

To make this more efficient, the actions field should only be included when it contains meaningful data. The ideal solution would be to change the definition in src/google/adk/events/event.py to actions: Optional[EventActions] = None. This would allow the existing if field_value is not None: check to correctly filter out cases where no actions are present. Since that change is outside this PR's scope, this is a good candidate for a follow-up task.

Comment on lines +175 to +177
assert result[f"{ADK_METADATA_KEY_PREFIX}actions"] == {
"test_actions": "value"
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This test assertion highlights a pre-existing inconsistency in event_converter.py. The _get_context_metadata function is type-hinted to return Dict[str, str], but this test correctly asserts that the value for the actions key is a dictionary, not a string.

While the A2A server expects Dict[str, Any] for metadata and this will work at runtime, the incorrect type hints are misleading and harm code maintainability.

To resolve this, the type hints in event_converter.py should be updated in a follow-up:

  • _get_context_metadata's return type should be Dict[str, Any].
  • _serialize_metadata_value's name, docstring, and return type hint should be changed to reflect that it can return non-string values (e.g., return type Any).

@ryanaiagent ryanaiagent self-assigned this Nov 21, 2025
@ryanaiagent ryanaiagent added a2a [Component] This issue is related a2a support inside ADK. needs-review [Status] The PR is awaiting review from the maintainer and removed core [Component] This issue is related to the core interface and implementation labels Nov 21, 2025
@ryanaiagent
Copy link
Collaborator

Hi @DeanChensj , can you please review this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a2a [Component] This issue is related a2a support inside ADK. needs-review [Status] The PR is awaiting review from the maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add EventActions to ADK->A2A conversion

3 participants