Skip to content

[dotnet-code] Consolidate workflow edge connection construction #768

Description

@github-actions

Summary

Centralized internal workflow edge-connection construction behind unexported helpers and routed the builder's direct, fan-out, and fan-in edge creation through them. This keeps Go's internal construction shape closer to the .NET EdgeConnection constructor pattern while preserving the existing exported struct and behavior.

.NET Reference

  • dotnet/src/Microsoft.Agents.AI.Workflows/Execution/EdgeConnection.cs - defines EdgeConnection as an ordered source/sink connection object constructed from source and sink ID lists.

Public API and Behavior

No public Go API changed. No intentional behavior change was made.

Tests

  • go test ./workflow
  • go test ./workflow/...

Notes

Rejected sampled candidates:

  • dotnet/src/Microsoft.Agents.AI.Workflows/Execution/MessageDelivery.cs - the nearest Go delivery mapping structure is already internal but differs in runtime shape; changing it would risk churn beyond a tiny cleanup.
  • dotnet/src/Microsoft.Agents.AI.Workflows/SuperStepEvent.cs - closer alignment would imply string/event surface changes, which could affect behavior or public API expectations.
  • dotnet/src/Microsoft.Agents.AI.Workflows/Execution/RunnerStateData.cs - Go runner state includes additional request-owner maps, so structural alignment was not a safe tiny refactor.

Generated by .NET-to-Go Code Portability Refactoring Agent · gpt55 · 89.5 AIC · ⌖ 10.6 AIC · ⊞ 23.2K ·


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-code-edge-connection-helpers-1e727db462061ccd.

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 (79 of 79 lines)
From 6d001b5affc2d440f850dd38c5754bcb7abb70bc Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Wed, 29 Jul 2026 22:42:45 +0000
Subject: [PATCH] Consolidate workflow edge connection construction

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 workflow/builder.go | 17 ++++-------------
 workflow/edge.go    | 11 +++++++++++
 2 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/workflow/builder.go b/workflow/builder.go
index 21f3ae5bc..ae83a5842 100644
--- a/workflow/builder.go
+++ b/workflow/builder.go
@@ -143,10 +143,7 @@ func (wb *Builder) AddDirectEdge(source ExecutorBinding, target ExecutorBinding,
 	if wb.err != nil {
 		return wb
 	}
-	conn := EdgeConnection{
-		SourceIDs: []string{source.ID},
-		SinkIDs:   []string{target.ID},
-	}
+	conn := newDirectEdgeConnection(source.ID, target.ID)
 	if condition == nil && slices.ContainsFunc(wb.conditionlessConnections, func(c EdgeConnection) bool {
 		return conn.Equal(c)
 	}) {
@@ -193,10 +190,7 @@ func (wb *Builder) AddFanOutEdge(source ExecutorBinding, targets []ExecutorBindi
 		}
 		sinkIDs = append(sinkIDs, target.ID)
 	}
-	conn := EdgeConnection{
-		SourceIDs: []string{source.ID},
-		SinkIDs:   sinkIDs,
-	}
+	conn := newEdgeConnection([]string{source.ID}, sinkIDs)
 	edge := Edge{
 		Connection: conn,
 		Index:      wb.edgeIdx(),
@@ -223,11 +217,8 @@ func (wb *Builder) AddFanInBarrierEdge(sources []ExecutorBinding, target Executo
 		sourceIDs = append(sourceIDs, source.ID)
 	}
 	edge := Edge{
-		Connection: EdgeConnection{
-			SourceIDs: sourceIDs,
-			SinkIDs:   []string{target.ID},
-		},
-		Index: wb.edgeIdx(),
+		Connection: newEdgeConnection(sourceIDs, []string{target.ID}),
+		Index:      wb.edgeIdx(),
 	}
 	applyEdgeOptions(&edge, opts)
 	for _, id := range sourceIDs {
diff --git a/workflow/edge.go b/workflow/edge.go
index f2941b9d7..87ba7e7b1 100644
--- a/workflow/edge.go
+++ b/workflow/edge.go
@@ -79,6 +79,17 @@ type
... (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