Skip to content

A2A inbound converters do not restore custom_metadata and drop metadata-only events #5185

Description

@YizukiAme

Bug Description

The public inbound converters convert_a2a_message_to_event() and convert_a2a_task_to_event() in to_adk_event.py only restore actions from A2A metadata. Other ADK event metadata fields (custom_metadata, usage_metadata, error_code, long_running_tool_ids, etc.) are silently dropped.

Additionally, _create_event() returns None when there are no parts and no actions, even if event_metadata is present. This means metadata-only A2A messages are discarded entirely.

Steps to Reproduce

from a2a.types import Message, Part, TextPart, Role

msg = Message(
    role=Role.agent,
    parts=[],
    metadata={"adk_custom_metadata": {"flag": True}}
)
event = convert_a2a_message_to_event(msg, author="agent")
assert event is not None  # FAILS — metadata-only message silently dropped

Expected Behavior

  • custom_metadata, usage_metadata, and other semantic metadata fields should be restored on the resulting Event
  • Metadata-only messages (no content parts, but valid metadata) should produce a valid Event with content=None

Affected Files

  • src/google/adk/a2a/converters/to_adk_event.py

Activity

  1. added theissue type on Apr 8, 2026
  2. added
    core
    on Apr 8, 2026
  3. added 2 commits that reference this issue on Apr 9, 2026
    484aee4
    bc8a9d6
  4. llalitkumarrr commented on Apr 9, 2026

    @llalitkumarrr
    Collaborator

    Hello @YizukiAme ,

    Thank you for raising this issue. We were able to reproduce it and observed the same behavior. There is a PR linked to this issue currently under review. It will be merged once all tests pass and the changes are approved.

    Hello @wyf7107 ,
    Could you please look at this? We also observed that some fields like usage_metadata return None when the event is returned by a remote agent. We use google-adk==1.28.0 for this reproduction.

  5. added
    needs review
    on Apr 9, 2026
  6. self-assigned this
    on Aug 6, 2026
  7. GWeale commented on Aug 6, 2026

    @GWeale
    Collaborator

    restoring custom_metadata shipped in 2.6.0, and a metadata-only message comes back as an event on main. one gap is left, the message converter still drops long_running_tool_ids, so please file that separately.

  8. reopened this on Aug 10, 2026
  9. danieldutu commented on Oct 23, 2026

    @danieldutu
    Contributor

    I ran the repro from this issue on main at f08f9d6: convert_a2a_message_to_event(Message(message_id="m1", role=ROLE_AGENT, parts=[], metadata={"adk_custom_metadata": {"flag": True}}), author="agent") returns None, so the metadata-only message is still dropped, which differs from the 2026-08-06 comment. The cause is _create_event at to_adk_event.py:215-220, which returns None for no parts and no actions, while the message converter never marks the extracted metadata as content. I have a one-line fix limited to the message converter, with a test next to the action-only test. The task and status-update paths stay as they are because test_contentless_progress_does_not_emit_a_final_response requires them to drop metadata-only progress. I plan to open a PR for this.

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

Metadata

Metadata

Labels

coreneeds review

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions