mirror of
https://github.com/encounter/adk-python.git
synced 2026-07-09 18:19:28 -07:00
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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user