Skip to content

[dotnet-port] Populate MessageID from TaskStatusUpdateEvent.Status.Message in A2A agent #211

Description

@github-actions

Summary

When the Go A2A agent receives a TaskStatusUpdateEvent during streaming, ResponseUpdate.MessageID was always set to the TaskID. The upstream .NET fix (microsoft/agent-framework#6043) corrects this by using the message ID from Status.Message.MessageId when that message is present — providing accurate per-message correlation metadata instead of the task-level ID.

This PR ports that fix: MessageID is now populated from e.Status.Message.ID when the status update carries a message, falling back to string(e.TaskID) when no message is present (preserving the existing behavior for status events without a message).

Ported .NET PRs

Upstream commit: abc9b60ec9943670a5dbe14d2a06a701b0475481

Breaking Changes

No. The fallback to TaskID preserves the existing behavior when Status.Message is nil.

Tests and Examples

  • Updated agent/provider/a2aagent/a2a.go with the fix.
  • Added TestRunStreamingWithTaskStatusUpdateEvent_WithMessage to agent/provider/a2aagent/a2a_test.go which verifies that MessageID is taken from Status.Message.ID when present, and that ResponseID remains the TaskID.
  • Existing TestRunStreamingWithTaskStatusUpdateEvent continues to exercise the fallback path (no message in status).
  • All tests pass: go test ./agent/provider/a2aagent/...

Notes

Other new upstream commits (793403f3 MCP long-running task support, 9fdd7429 Magentic orchestration sample) were reviewed but not ported: the MCP long-running task feature introduces new .NET-specific abstractions not present in the Go SDK, and the Magentic sample depends on orchestration infrastructure not yet fully present in Go.

Generated by .NET to Go Porting Agent · ● 12.1M ·


Note

This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository.
The changes have been pushed to branch dotnet-port-a2a-messageid-fix-abc9b60e-f053653b0253c814.

Click here to create the pull request

To fix the permissions issue, go to SettingsActionsGeneral and enable Allow GitHub Actions to create and approve pull requests. See also: gh-aw FAQ

Show patch preview (102 of 102 lines)
From 603e3a96d4bcca91d2d4b9410fbff2a4f285888b Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Sat, 23 May 2026 09:34:04 +0000
Subject: [PATCH] fix: populate MessageID from
 TaskStatusUpdateEvent.Status.Message

When the Go A2A agent receives a TaskStatusUpdateEvent during streaming,
ResponseUpdate.MessageID is now set from Status.Message.ID when the
message is present, falling back to the TaskID otherwise.

This aligns with the .NET fix in microsoft/agent-framework#6043.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 agent/provider/a2aagent/a2a.go      |  6 +++-
 agent/provider/a2aagent/a2a_test.go | 49 +++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+), 1 deletion(-)

diff --git a/agent/provider/a2aagent/a2a.go b/agent/provider/a2aagent/a2a.go
index 33619973..ac273f14 100644
--- a/agent/provider/a2aagent/a2a.go
+++ b/agent/provider/a2aagent/a2a.go
@@ -179,10 +179,14 @@ func sendMsg(session *agent.Session, seq iter.Seq2[a2a.Event, error], yield func
 				return
 			}
 		case *a2a.TaskStatusUpdateEvent:
+			messageID := string(e.TaskID)
+			if e.Status.Message != nil {
+				messageID = e.Status.Message.ID
+			}
 			if !yield(&agent.ResponseUpdate{
 				RawRepresentation:    e,
 				AdditionalProperties: e.Metadata,
-				MessageID:            string(e.TaskID),
+				MessageID:            messageID,
 				ResponseID:           string(e.TaskID),
 				Role:                 message.RoleAssistant,
 				CreatedAt:            time.Now(),
diff --git a/agent/provider/a2aagent/a2a_test.go b/agent/provider/a2aagent/a2a_test.go
index 7b9ddec7..089e5b66 100644
--- a/agent/provider/a2aagent/a2a_test.go
+++ b/agent/provider/a2aagent/a2a_test.go
@@ -1338,6 +1338,55 @@ func TestRunStreamingWithTaskStatusUpdateEvent(t *testing.T) {
 	}
 }
 
+// TestRunStreamingWithTaskStatusUpdateEvent_WithMessage tests that MessageID is populated
+// from Status.Message.ID when the status update contains 
... (truncated)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions