-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Adds ADK EventActions to A2A response #3631
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -83,8 +83,7 @@ def setup_method(self): | |
| self.mock_event.error_message = None | ||
| self.mock_event.content = None | ||
| self.mock_event.long_running_tool_ids = None | ||
| self.mock_event.actions = Mock(spec=EventActions) | ||
| self.mock_event.actions.artifact_delta = None | ||
| self.mock_event.actions = None | ||
|
|
||
| def test_get_adk_event_metadata_key_success(self): | ||
| """Test successful metadata key generation.""" | ||
|
|
@@ -161,6 +160,8 @@ def test_get_context_metadata_with_optional_fields(self): | |
| mock_metadata = Mock() | ||
| mock_metadata.model_dump.return_value = {"test": "value"} | ||
| self.mock_event.grounding_metadata = mock_metadata | ||
| self.mock_event.actions = Mock() | ||
| self.mock_event.actions.model_dump.return_value = {"test_actions": "value"} | ||
|
|
||
| result = _get_context_metadata( | ||
| self.mock_event, self.mock_invocation_context | ||
|
|
@@ -169,7 +170,11 @@ def test_get_context_metadata_with_optional_fields(self): | |
| assert result is not None | ||
| assert f"{ADK_METADATA_KEY_PREFIX}branch" in result | ||
| assert f"{ADK_METADATA_KEY_PREFIX}grounding_metadata" in result | ||
| assert f"{ADK_METADATA_KEY_PREFIX}actions" in result | ||
| assert result[f"{ADK_METADATA_KEY_PREFIX}branch"] == "test-branch" | ||
| assert result[f"{ADK_METADATA_KEY_PREFIX}actions"] == { | ||
| "test_actions": "value" | ||
| } | ||
|
Comment on lines
+175
to
+177
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This test assertion highlights a pre-existing inconsistency in While the A2A server expects To resolve this, the type hints in
|
||
|
|
||
| # Check if error_code is in the result - it should be there since we set it | ||
| if f"{ADK_METADATA_KEY_PREFIX}error_code" in result: | ||
|
|
||
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.
The
actionsfield on anEventobject is initialized withdefault_factory=EventActions, soevent.actionswill never beNone. 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
actionsfield should only be included when it contains meaningful data. The ideal solution would be to change the definition insrc/google/adk/events/event.pytoactions: Optional[EventActions] = None. This would allow the existingif 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.