Skip to content

Python: fix: consistent response_id and metadata forwarding in A2AAgent#5288

Open
LEDazzio01 wants to merge 2 commits intomicrosoft:mainfrom
LEDazzio01:fix/a2a-response-id-and-metadata
Open

Python: fix: consistent response_id and metadata forwarding in A2AAgent#5288
LEDazzio01 wants to merge 2 commits intomicrosoft:mainfrom
LEDazzio01:fix/a2a-response-id-and-metadata

Conversation

@LEDazzio01
Copy link
Copy Markdown
Contributor

Fixes

Changes

response_id consistency (#5263)

The A2AMessage path was using message_id as response_id, while all Task-based paths use task.id. This caused inconsistent response_id values across response types.

Fix: Use task_id for response_id (with UUID fallback) and set message_id as a separate field, matching the issue reporter's suggested approach.

metadata forwarding (#5240)

Part-level metadata was correctly forwarded via _parse_contents_from_a2a(), but message/event-level metadata was dropped in three places:

  1. A2AMessage pathitem.metadata was not forwarded
  2. TaskArtifactUpdateEventupdate_event.artifact.metadata was not forwarded
  3. TaskStatusUpdateEventupdate_event.status.message.metadata was not forwarded

Fix: Add additional_properties= to each AgentResponseUpdate constructor.

Tests

Added 7 new tests covering:

  • response_id uses task_id when present
  • response_id falls back to UUID when task_id absent
  • message_id preserved separately from response_id
  • Metadata forwarded from A2AMessage, TaskArtifactUpdateEvent, TaskStatusUpdateEvent

Updated 2 existing tests to reflect the new response_id behavior.

Fix microsoft#5263: Use task_id (not message_id) for response_id in the
A2AMessage path, matching the behavior of all Task-based paths.
message_id is now set as a separate field on AgentResponseUpdate.

Fix microsoft#5240: Forward metadata as additional_properties from:
- A2AMessage (message-level metadata)
- TaskArtifactUpdateEvent (artifact metadata)
- TaskStatusUpdateEvent (status message metadata)

Previously, only Part-level metadata was forwarded via
_parse_contents_from_a2a(). Message/event-level metadata was dropped.
Copilot AI review requested due to automatic review settings April 15, 2026 23:01
@github-actions github-actions bot changed the title fix: consistent response_id and metadata forwarding in A2AAgent Python: fix: consistent response_id and metadata forwarding in A2AAgent Apr 15, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes A2AAgent’s Python A2A-stream mapping so response_id is consistent across A2AMessage vs task-based responses, and ensures message/event-level metadata is forwarded into AgentResponseUpdate.additional_properties.

Changes:

  • Use task_id (with UUID fallback) as response_id for A2AMessage updates, while preserving message_id separately.
  • Forward metadata from A2AMessage, TaskArtifactUpdateEvent, and TaskStatusUpdateEvent into AgentResponseUpdate.additional_properties.
  • Add/update unit tests covering response_id behavior and metadata forwarding.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
python/packages/a2a/agent_framework_a2a/_agent.py Aligns A2AMessage response_id with task-based paths; forwards message/event metadata into updates.
python/packages/a2a/tests/test_a2a_agent.py Updates existing expectations and adds new tests for response_id, message_id, and metadata forwarding.

Comment on lines +1410 to +1412
mock_a2a_client.add_message_response(
"msg-abc", "Hello", task_id="task-xyz"
)
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These arguments are split across lines in a way that doesn’t match the repo’s Ruff formatter output. Please run ruff format (or adjust line breaks / trailing commas) so CI formatting checks pass.

Suggested change
mock_a2a_client.add_message_response(
"msg-abc", "Hello", task_id="task-xyz"
)
mock_a2a_client.add_message_response("msg-abc", "Hello", task_id="task-xyz")

Copilot uses AI. Check for mistakes.
) -> None:
"""Test that A2AMessage metadata is forwarded as additional_properties (#5240)."""
mock_a2a_client.add_message_response(
"msg-meta", "Hello", task_id="task-meta",
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call formatting (mixed arguments on the same line plus line breaks) is not Ruff-format compliant. Please reformat (e.g., one-line call or one-arg-per-line with trailing commas) to satisfy ruff format.

Suggested change
"msg-meta", "Hello", task_id="task-meta",
"msg-meta",
"Hello",
task_id="task-meta",

Copilot uses AI. Check for mistakes.
Comment on lines +1427 to +1429
# Should be a valid UUID string, not message_id
assert response.response_id != "msg-no-task"
assert len(response.response_id) > 0
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test says response_id should fall back to a UUID, but the assertions only check non-emptiness and inequality with the message_id. Please validate the value is actually a UUID (e.g., UUID(response.response_id) succeeds) so the test would fail if the fallback regressed.

Copilot uses AI. Check for mistakes.
Comment on lines +1505 to +1507
mock_a2a_client.add_message_response(
"msg-unique", "Hello", task_id="task-parent"
)
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call’s multiline formatting doesn’t match Ruff’s formatter conventions and may fail formatting checks. Please reformat (or run ruff format).

Suggested change
mock_a2a_client.add_message_response(
"msg-unique", "Hello", task_id="task-parent"
)
mock_a2a_client.add_message_response("msg-unique", "Hello", task_id="task-parent")

Copilot uses AI. Check for mistakes.
- Collapse short multiline calls to single-line (3 instances)
- Reformat mixed-args call to one-arg-per-line with trailing commas
- Replace len() > 0 assertion with UUID() parse for proper validation
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.

3 participants