feat: Adds ADK EventActions to A2A response

Merge https://github.com/google/adk-python/pull/3631

### Link to Issue or Description of Change

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

- Closes: #3630

**Solution:**
Adds [Event.actions](https://github.com/google/adk-python/blob/a3aa07722a7de3e08807e86fd10f28938f0b267d/src/google/adk/events/event.py#L51) 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

COPYBARA_INTEGRATE_REVIEW=https://github.com/google/adk-python/pull/3631 from hoonji:main 31d3a49ad630bbd778aa4cf62dd9ccfc50f5b7af
PiperOrigin-RevId: 842274939
This commit is contained in:
hoonji
2025-12-09 09:32:36 -08:00
committed by Copybara-Service
parent 56775afc48
commit 32e87f6381
2 changed files with 8 additions and 2 deletions
@@ -140,6 +140,7 @@ def _get_context_metadata(
("custom_metadata", event.custom_metadata),
("usage_metadata", event.usage_metadata),
("error_code", event.error_code),
("actions", event.actions),
]
for field_name, field_value in optional_fields:
@@ -66,8 +66,7 @@ class TestEventConverter:
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."""
@@ -144,6 +143,8 @@ class TestEventConverter:
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
@@ -152,7 +153,11 @@ class TestEventConverter:
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"
}
# 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: