microsoft / microsoft/agent-framework-go
[dotnet-code] Extract portable message unwrap helper
- Dominant language
- Go
- Stars
- 618
- Forks
- 56
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 122
Description
> [!TIP]
> **Your pull request is ready to create! 🎉 ✅**
>
> Everything is OK—the changes have been pushed to branch `dotnet-code-message-router-unwrap-20260918222921-0aed06660944a6f8`. Please review the changes, including any protected files, before creating the pull request.
>
> **[Create the pull request](https://github.com/microsoft/agent-framework-go/compare/main...dotnet-code-message-router-unwrap-20260918222921-0aed06660944a6f8?expand=1&title=%5Bdotnet-code%5D%20Extract%20portable%20message%20unwrap%20helper)**
>
> The original pull request description is below.
---
## Summary
Extracts the workflow message router's `PortableValue` unwrapping into a small unexported helper. This keeps Go routing behavior the same while making the route flow more structurally similar to the .NET `MessageRouter.RouteMessageAsync` conversion step, which should make future .NET-to-Go comparisons easier.
## .NET Reference
- `dotnet/src/Microsoft.Agents.AI.Workflows/Execution/MessageRouter.cs` - unwraps `PortableValue` messages to the registered runtime type before handler lookup.
## Public API and Behavior
No public Go API changed. No intentional behavior change was made.
## Tests
- `gofmt -w workflow/route.go`
- `go test ./workflow`
## Notes
Rejected candidates:
- `dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Interpreter/WorkflowModel.cs` - no current Go declarative workflow counterpart was found, so a structural cleanup would be speculative.
- `dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.Mcp.UnitTests/DefaultMcpToolHandlerTests.cs` - nearest Go MCP areas are provider/tool-facing and broader than the requested tiny portability cleanup.
- Open approved `[dotnet-code]` PR found: #1092, covering compaction rather than this workflow router area. Two lower-integrity PR search results were filtered by the environment and were not inspected.
The upstream .NET `git fetch` was blocked by the environment network boundary, so the .NET reference was sampled/read via the read-only GitHub MCP CLI instead.
---
> [!NOTE]
> GitHub Actions is not permitted to create or approve pull requests in this repository.
> The changes have been pushed to branch `dotnet-code-message-router-unwrap-20260918222921-0aed06660944a6f8` and are ready to review.
To fix the permissions issue, go to **Settings** → **Actions** → **General** and enable **Allow GitHub Actions to create and approve pull requests**. See also: [gh-aw FAQ](https://github.github.com/gh-aw/reference/faq/#why-is-my-create-pull-request-workflow-failing-with-github-actions-is-not-permitted-to-create-or-approve-pull-requests)
Show patch (55 lines)
```diff
From ecec28290c4b1b2205510fe8c59a1ed48274ae41 Mon Sep 17 00:00:00 2001
X-GH-AW-Base-Commit: 4bb6efb22f814ba17a93d0aff7110b0c1dbe46f9
From: "github-actions[bot]"
Date: Fri, 18 Sep 2026 22:29:21 +0000
Subject: [PATCH] [dotnet-code] Extract portable message unwrap helper
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
workflow/route.go | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/workflow/route.go b/workflow/route.go
index a396f0e..34780e3 100644
--- a/workflow/route.go
+++ b/workflow/route.go
@@ -263,14 +263,7 @@ func (mr *messageRouter) routeMessage(ctx *Context, msg any) (result callResult,
}
pvalue, isPortable := msg.(PortableValue)
if isPortable {
- if info, ok := mr.typeInfo(pvalue.TypeID); ok {
- if v, ok := pvalue.As(info.runtimeType); ok {
- // If we found a runtime type, we can use it
- msg = v
- }
- } else if value := pvalue.Any(); value != nil && pvalue.TypeID.MatchPolymorphic(reflect.TypeOf(value)) {
- msg = value
- }
+ msg = mr.unwrapPortableMessage(pvalue)
}
defer func() {
if r := recover(); r != nil {
@@ -297,6 +290,19 @@ func (mr *messageRouter) routeMessage(ctx *Context, msg any) (result callResult,
return callResult{}, false
}
+func (mr *messageRouter) unwrapPortableMessage(pvalue PortableValue) any {
+ if info, ok := mr.typeInfo(pvalue.TypeID); ok {
+ if v, ok := pvalue.As(info.runtimeType); ok {
+ return v
+ }
+ return pvalue
+ }
+ if value := pvalue.Any(); value != nil && pvalue.TypeID.MatchPolymorphic(reflect.TypeOf(value)) {
+ return value
+ }
+ return pvalue
+}
+
func (mr *messageRouter) typeInfo(typeID TypeID) (typeHandlingInfo, bool) {
if typeID == (TypeID{}) {
return typeHandlingInfo{}, false
--
2.54.0
```
> [!WARNING]
>
> Firewall blocked 1 domain
>
> The following domain was blocked by the firewall during workflow execution:
>
> - `github.com`
>
> To allow these domains, add them to the `network.allowed` list in your workflow frontmatter:
>
> ```yaml
> network:
> allowed:
> - defaults
> - "github.com"
> ```
>
> See [Network Configuration](https://github.github.com/gh-aw/reference/network/) for more information.
>
>
> Generated by [.NET-to-Go Code Portability Refactoring Agent](https://github.com/microsoft/agent-framework-go/actions/runs/35401518517) · copilot · gpt55 · 55.6 AIC · ⌖ 13.4 AIC · ⊞ 14.9K · [◷](https://github.com/search?q=repo%3Amicrosoft%2Fagent-framework-go+%22gh-aw-workflow-id%3A+dotnet-code-portability-nightly%22&type=pullrequests)
Contributor guide
Research direction
Read workflow/route.go and inspect routeMessage alongside the proposed unwrapPortableMessage helper. Run go test ./workflow and confirm the refactor preserves existing portable-message routing behavior without changing the public Go API.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 25/100