Skip to content

[dotnet-code] Consolidate workflow edge registration #326

Description

@github-actions

Summary

Centralized workflow builder edge insertion behind an unexported helper so direct, fan-out, and fan-in paths share the same internal registration shape. This mirrors the .NET WorkflowBuilder pattern of routing edge storage through a single internal method and should make future .NET-to-Go workflow ports easier to compare.

.NET Reference

  • dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowBuilder.cs - workflow builder stores edges through an internal edge collection helper.

Public API and Behavior

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

Tests

  • go test ./workflow/...

Notes

Rejected sampled candidates:

  • dotnet/src/Microsoft.Agents.AI/Harness/Loop/LoopEvaluator.cs vs agent/harness/loop/evaluators.go: Go shape is already small and direct; no safe cleanup found.
  • dotnet/src/Microsoft.Agents.AI.Abstractions/AIAgentMetadata.cs vs agent/agent.go: metadata/provider accessors are already minimal in Go; changes would risk public API churn.
  • dotnet/src/Microsoft.Agents.AI.Workflows/TurnToken.cs: no narrow corresponding Go internal cleanup was identified without adding a missing feature or placeholder.

Generated by .NET-to-Go Code Portability Refactoring Agent · 284 AIC · ⌖ 29.4 AIC · ⊞ 20.8K ·


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/workflow-edge-registration-a35e83ce8fd245b9.

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 (58 of 58 lines)
From e10422399c3c83ad0b31cd326a7962fa24b95ca4 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Fri, 19 Jun 2026 22:40:58 +0000
Subject: [PATCH] Consolidate workflow edge registration

Centralize workflow builder edge insertion behind an unexported helper so direct, fan-out, and fan-in edge paths share the same internal registration shape.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 workflow/builder.go | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/workflow/builder.go b/workflow/builder.go
index 581e8a1ff..40e051651 100644
--- a/workflow/builder.go
+++ b/workflow/builder.go
@@ -127,7 +127,7 @@ func (wb *Builder) AddDirectEdge(source ExecutorBinding, target ExecutorBinding,
 		Index:      wb.edgeIdx(),
 	}
 	applyEdgeOptions(&edge, opts)
-	wb.edges[source.ID] = append(wb.edges[source.ID], edge)
+	wb.addEdgeForSource(source.ID, edge)
 	wb.conditionlessConnections = append(wb.conditionlessConnections, conn)
 	return wb
 }
@@ -159,7 +159,7 @@ func (wb *Builder) AddFanOutEdge(source ExecutorBinding, targets []ExecutorBindi
 		Index:      wb.edgeIdx(),
 	}
 	applyEdgeOptions(&edge, opts)
-	wb.edges[source.ID] = append(wb.edges[source.ID], edge)
+	wb.addEdgeForSource(source.ID, edge)
 	return wb
 }
 
@@ -188,7 +188,7 @@ func (wb *Builder) AddFanInBarrierEdge(sources []ExecutorBinding, target Executo
 	}
 	applyEdgeOptions(&edge, opts)
 	for _, id := range sourceIDs {
-		wb.edges[id] = append(wb.edges[id], edge)
+		wb.addEdgeForSource(id, edge)
 	}
 	return wb
 }
@@ -337,6 +337,10 @@ func (wb *Builder) edgeIdx() int {
 	return wb.edgeCount
 }
 
+func (wb *Builder) addEdgeForSource(sourceID string, edge Edge) {
+	wb.edges[sourceID] = append(wb.edges[sourceID], edge)
+}
+
 // validateTypeCompatibility checks that sent message types of source executors
 // are compatible with input types of target executors for every edge. It
 // creates temporary executor ins
... (truncated)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions