Skip to content

[dotnet-code] Clarify message workflow route handlers #773

Description

@github-actions

Summary

Refactored the message workflow Configure route registration so each incoming route delegates to a small unexported helper for accumulating messages or taking a turn. This keeps the registration shape closer to the .NET workflow router separation while preserving the existing accepted message types and turn-token behavior.

.NET Reference

  • dotnet/src/Microsoft.Agents.AI.Workflows/IMessageRouter.cs - internal workflow router interface separates route capability from message dispatch.

Public API and Behavior

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

Tests

  • go test ./message/messageworkflow

Notes

Rejected candidates from the random sample:

  • dotnet/src/Microsoft.Agents.AI/Harness/FileStore/FileLineEdit.cs - no close Go file-store editing counterpart in the current sampled Go areas, so a portability cleanup would have been speculative.
  • dotnet/src/Microsoft.Agents.AI.Hosting.OpenAI/IdGenerator.cs - no corresponding Go ID generator was found in the sampled repository paths.
  • dotnet/src/Microsoft.Agents.AI/Harness/FileMemory/FileMemoryProvider.cs - the nearby Go Foundry memory provider is a different provider surface; changing it based on the file-memory reference risked unrelated behavior churn.

Generated by .NET-to-Go Code Portability Refactoring Agent · gpt55 · 140.7 AIC · ⌖ 17.9 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/messageworkflow-route-helpers-30670671754-257c6cc1164bb57e.

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 (124 of 124 lines)
From 3916efc90a4c6d14a880bfdfb0041766c7bd8f90 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Fri, 31 Jul 2026 22:43:09 +0000
Subject: [PATCH] Refactor message workflow route handlers

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 message/messageworkflow/messageworkflow.go | 95 +++++++++++++---------
 1 file changed, 55 insertions(+), 40 deletions(-)

diff --git a/message/messageworkflow/messageworkflow.go b/message/messageworkflow/messageworkflow.go
index 3d6f74f28..f4d34d8be 100644
--- a/message/messageworkflow/messageworkflow.go
+++ b/message/messageworkflow/messageworkflow.go
@@ -90,50 +90,65 @@ func Configure(executor *workflow.Executor, options *Options) {
 				rb.SendsMessageType(reflect.TypeFor[workflow.TurnToken]())
 			}
 			if options.StringMessageRole != "" {
-				rb.RouteBuilder.AddHandlerRaw(reflect.TypeFor[string](), nil, func(ctx *workflow.Context, msg any) (any, error) {
-					return struct{}{}, state.ProcessTurnMessages(ctx, func(ctx *workflow.Context, messages []*message.Message) ([]*message.Message, error) {
-						return append(messages, &message.Message{
-							Role:     message.Role(options.StringMessageRole),
-							Contents: []message.Content{&message.TextContent{Text: msg.(string)}},
-						}), nil
-					})
-				})
+				rb.RouteBuilder.AddHandlerRaw(reflect.TypeFor[string](), nil, accumulateStringMessage(state, message.Role(options.StringMessageRole)))
 			}
 			rb.RouteBuilder.
-				AddHandlerRaw(reflect.TypeFor[*message.Message](), nil, func(ctx *workflow.Context, msg any) (any, error) {
-					return struct{}{}, state.ProcessTurnMessages(ctx, func(ctx *workflow.Context, messages []*message.Message) ([]*message.Message, error) {
-						return append(messages, msg.(*message.Message)), nil
-					})
-				}).
-				AddHandlerRaw(reflect.TypeFor[[]*message.Message](), nil, func(ctx *workflow.Context, msgs any) (any, error) {
-					return struct{}{}, state.Pro
... (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