Skip to content

Python: Propagate A2A metadata from Message, Artifact, Task, and event types#5256

Open
kartikmadan11 wants to merge 1 commit intomicrosoft:mainfrom
kartikmadan11:fix/5240-a2a-metadata-propagation
Open

Python: Propagate A2A metadata from Message, Artifact, Task, and event types#5256
kartikmadan11 wants to merge 1 commit intomicrosoft:mainfrom
kartikmadan11:fix/5240-a2a-metadata-propagation

Conversation

@kartikmadan11
Copy link
Copy Markdown
Contributor

Motivation and Context

The A2A protocol defines a metadata field on Message, Artifact, Task, TaskStatusUpdateEvent, and TaskArtifactUpdateEvent. Currently, A2AAgent only propagates Part-level metadata (via _parse_contents_from_a2a), but silently drops metadata at every other level, losing information transmitted by the server.

Fixes #5240

Description

Metadata is now propagated at each conversion boundary in _agent.py:

A2A Type Target How
Message AgentResponseUpdate.additional_properties message.metadata directly
Artifact intermediate Message.additional_properties → merged into update artifact.metadata on Message, then merged with task.metadata
Task AgentResponseUpdate.additional_properties task.metadata on all updates produced from the task
TaskArtifactUpdateEvent AgentResponseUpdate.additional_properties {**artifact.metadata, **event.metadata} merged
TaskStatusUpdateEvent AgentResponseUpdate.additional_properties {**message.metadata, **event.metadata} merged
History Message Message.additional_properties history_item.metadata directly

For streaming events, metadata from the inner object (artifact or status message) is merged with the outer event metadata, since they represent different layers of information.

Eight regression tests cover all affected types plus a None-safety check.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass (74/74 in a2a package), and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

…t types

A2AAgent was only propagating Part-level metadata but silently dropping
metadata from Message, Artifact, Task, TaskStatusUpdateEvent, and
TaskArtifactUpdateEvent. This adds metadata propagation at each
conversion boundary so server-transmitted metadata is preserved on
AgentResponseUpdate.additional_properties.

For streaming events (TaskArtifactUpdateEvent, TaskStatusUpdateEvent),
metadata from the inner object (artifact/message) is merged with the
outer event metadata.

Adds 8 regression tests covering all affected types plus None-safety.

Fixes microsoft#5240
@moonbox3
Copy link
Copy Markdown
Contributor

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/a2a/agent_framework_a2a
   _agent.py2391693%352, 357, 359, 520, 537, 545, 566, 587, 608, 628, 642, 656, 668–669, 711–712
TOTAL27546319688% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
5578 20 💤 0 ❌ 0 🔥 1m 30s ⏱️

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Python A2AAgent Implementation Currently Ignores Metadata in TaskArtifactUpdateEvent

3 participants