Skip to content

[dotnet-port-fixes] Suppress duplicate hosted workflow responses #735

Description

@github-actions

Summary

Align workflow/agentworkflow with the .NET hosted-workflow fix from microsoft/agent-framework#7217 (upstream commit bfc73a5b14b40d40a90bf949d601324894d1bc34).

This change:

  • synthesizes stable message IDs for contentful hosted-agent streaming updates when the provider does not supply one
  • suppresses completed *agent.Response messages that were already surfaced as streamed updates when IncludeOutputsInResponse is enabled
  • preserves the hosted response completion event as a raw-only observability update in streaming mode
  • adds end-to-end tests covering duplicate suppression with and without provider-supplied message IDs

Ported .NET PRs

Breaking Changes

No.

Tests and Examples

  • Added workflow tests for hosted-agent duplicate suppression and completion-event observability
  • go test ./workflow/agentworkflow
  • go test ./...
  • No examples changed

Notes

  • Upstream evidence: dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowSession.cs, dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/AIAgentHostExecutor.cs
  • The duplicate suppression is intentionally scoped to completed hosted-agent *agent.Response outputs; existing IncludeOutputsInResponse behavior for non-hosted generic workflow message outputs is unchanged
  • Commit ported from upstream head e90b6de5a72d922ea3b803cf4f194e2f1bae354b inspected during selection

Generated by .NET to Go Fixes and Test Porting Agent · 1.1K AIC · ⌖ 18.6 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 copilot/dotnet-port-fixes-hosted-response-dedup-20260724-bcc912f62939d12b.

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 (313 of 313 lines)
From 92cf6f4f9e707ad2b466a02fd2229744d7883030 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Fri, 24 Jul 2026 03:44:06 +0000
Subject: [PATCH] [dotnet-port-fixes] Suppress duplicate hosted workflow
 responses

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 workflow/agentworkflow/hosting.go       |  50 ++++++++++++
 workflow/agentworkflow/workflow.go      |  38 ++++++++-
 workflow/agentworkflow/workflow_test.go | 103 +++++++++++++++++++++++-
 3 files changed, 189 insertions(+), 2 deletions(-)

diff --git a/workflow/agentworkflow/hosting.go b/workflow/agentworkflow/hosting.go
index f206b1818..be684359a 100644
--- a/workflow/agentworkflow/hosting.go
+++ b/workflow/agentworkflow/hosting.go
@@ -167,6 +167,12 @@ type hostExecutor struct {
 	turnEmitEvents  *bool
 }
 
+type generatedHostedMessageState struct {
+	messageID  string
+	responseID string
+	role       message.Role
+}
+
 func newHostExecutor(a *agent.Agent, cfg Config) *hostExecutor {
 	id := descriptiveID(a)
 	ports := hostPorts(id)
@@ -406,10 +412,12 @@ func (h *hostExecutor) runAgentAndDispatch(wctx *workflow.Context, messages []*m
 	}
 
 	var resp agent.Response
+	var generatedMessageState generatedHostedMessageState
 	for update, err := range h.agent.Run(wctx, agentInput, runOpts...) {
 		if err != nil {
 			return err
 		}
+		update = stampHostedUpdateMessageID(update, &generatedMessageState)
 		if emitUpdates {
 			if err := wctx.YieldOutput(update); err != nil {
 				return err
@@ -454,6 +462,48 @@ func (h *hostExecutor) runAgentAndDispatch(wctx *workflow.Context, messages []*m
 	return nil
 }
 
+func stampHostedUpdateMessageID(update *agent.ResponseUpdate, state *generatedHostedMessageState) *agent.ResponseUpdate {
+	if update == nil {
+		return nil
+	}
+	if update.MessageID != "" {
+		if state != nil {
+			*state = generatedHostedMessageState{}
+		}
+		return update
+	}
+	if !responseUpdateHasContent(update) || state ==
... (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