Skip to content

A2A _serialize_value() corrupts JSON-native metadata types to strings #5183

@YizukiAme

Description

@YizukiAme

Bug Description

_serialize_value() in from_adk_event.py falls through to str() for JSON-native Python types (dict, list, bool, int, float), corrupting structured metadata values into their string representations during A2A event conversion.

Steps to Reproduce

from google.adk.a2a.converters.from_adk_event import _serialize_value

metadata = {"retry": True, "max_attempts": 3, "tags": ["alpha", "beta"]}
result = _serialize_value(metadata)
print(type(result), result)
# Actual: <class 'str'> "{'retry': True, 'max_attempts': 3, 'tags': ['alpha', 'beta']}"
# Expected: <class 'dict'> {'retry': True, 'max_attempts': 3, 'tags': ['alpha', 'beta']}

Expected Behavior

JSON-native types (dict, list, str, bool, int, float) should be preserved as-is since they are already valid JSON values, not converted to strings.

Actual Behavior

All non-Pydantic values that aren't None are passed through str(), which corrupts structured data into Python repr strings.

Metadata

Metadata

Assignees

No one assigned

    Labels

    core[Component] This issue is related to the core interface and implementation

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions