Skip to content

[dotnet-port-fixes] Prefer terminal workflow outputs in collected responses #563

Description

@github-actions

Summary

Aligned workflow-as-agent collection with the upstream .NET fix from microsoft/agent-framework#6212 so non-streaming Collect() responses now prefer designated terminal workflow outputs over intermediate hosted-agent updates when both are present. The Go change stays internal to workflow/agentworkflow: it tracks terminal output-derived updates separately during collection, preserves existing streaming behavior, and adds a regression test covering intermediate hosted-agent outputs followed by a designated terminal workflow output.

Upstream references:

Ported .NET PRs

Breaking Changes

No.

Tests and Examples

  • Ran go test ./workflow/agentworkflow
  • Added TestNew_CollectPrefersTerminalWorkflowOutputOverIntermediateHostedAgentUpdates
  • Updated TestNew_IncludeOutputsInResponse to assert streaming visibility while collected responses prefer terminal workflow outputs

Notes

  • This port intentionally does not broaden Go's existing IncludeOutputsInResponse contract for generic workflow outputs; it only realigns final collected response selection.
  • No exported Go symbols were added or changed.

Generated by .NET to Go Fixes and Test Porting Agent · 1.3K AIC · ⌖ 29.9 AIC · ⊞ 21.7K ·


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-fixes-terminal-workflow-output-e1810b71550ce233.

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 (329 of 329 lines)
From aa4d2d0e0fb27b273e110a936a49f63dc7ba160b Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Mon, 20 Jul 2026 03:43:36 +0000
Subject: [PATCH] [dotnet-port-fixes] Prefer terminal workflow outputs in
 collected responses

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 workflow/agentworkflow/message_merger.go |  31 +++++++
 workflow/agentworkflow/workflow.go       |  51 +++++++----
 workflow/agentworkflow/workflow_test.go  | 107 ++++++++++++++++++++++-
 3 files changed, 172 insertions(+), 17 deletions(-)

diff --git a/workflow/agentworkflow/message_merger.go b/workflow/agentworkflow/message_merger.go
index df7bb5ce8..29fe5f1c3 100644
--- a/workflow/agentworkflow/message_merger.go
+++ b/workflow/agentworkflow/message_merger.go
@@ -88,6 +88,37 @@ func (m *messageMerger) ComputeMerged(primaryResponseID string, primaryAgentID s
 	return response
 }
 
+type collectedResponseMergeState struct {
+	allUpdates             *messageMerger
+	terminalWorkflowOutput *messageMerger
+	hasTerminalOutput      bool
+}
+
+func newCollectedResponseMergeState() *collectedResponseMergeState {
+	return &collectedResponseMergeState{
+		allUpdates:             newMessageMerger(),
+		terminalWorkflowOutput: newMessageMerger(),
+	}
+}
+
+func (s *collectedResponseMergeState) AddUpdate(update *agent.ResponseUpdate, terminalWorkflowOutput bool) {
+	if s == nil {
+		return
+	}
+	s.allUpdates.AddUpdate(update)
+	if terminalWorkflowOutput {
+		s.terminalWorkflowOutput.AddUpdate(update)
+		s.hasTerminalOutput = true
+	}
+}
+
+func (s *collectedResponseMergeState) ComputeMerged(primaryResponseID string, primaryAgentID string, primaryAgentName string) *agent.Response {
+	if s != nil && s.hasTerminalOutput {
+		return s.terminalWorkflowOutput.ComputeMerged(primaryResponseID, primaryAgentID, primaryAgentName)
+	}
+	return s.allUpdates.ComputeMerged(primaryResponseID, primaryAgentID, primaryAgentName)
+}
+
 type responseMe
... (truncated)

Activity

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

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