Skip to content

[dotnet-code] Extract content external request ID helper #771

Description

@github-actions

Summary

Extracted the content external handler's external request ID formatting into a small unexported helper and added focused tests for the pending-request state key and request ID formats. This keeps the Go internals closer to the .NET handler shape, where request key and external ID construction are dedicated helper operations, without changing behavior.

.NET Reference

  • dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/AIContentExternalHandler.cs - uses dedicated helpers for pending-request state keys and external request ID formatting.

Public API and Behavior

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

Tests

  • go test ./internal/contentexthandler
  • go test ./workflow/agentworkflow
  • Added preservation tests in internal/contentexthandler/contentexthandler_test.go.

Notes

Rejected sampled candidates:

  • dotnet/src/Microsoft.Agents.AI.A2A/A2AJsonUtilities.cs - Go's A2A provider shape centers on conversion helpers rather than equivalent serializer options, so no small safe cleanup was apparent.
  • dotnet/src/Microsoft.Agents.AI.Workflows/Observability/Tags.cs - the Go equivalent has similar constants, but key/name changes would be behavior-sensitive telemetry churn.
  • dotnet/src/Microsoft.Agents.AI/Skills/File/AgentFileSkillResource.cs - Go already reads file-backed resources through the skill filesystem with no useful narrow structural cleanup found.

Generated by .NET-to-Go Code Portability Refactoring Agent · gpt55 · 77.2 AIC · ⌖ 20.1 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-contentext-id-helper-56f6e2b7c8dc06cc.

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 (102 of 102 lines)
From 287049e944e4befc232b742c91155eeb8699cdbc Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Thu, 30 Jul 2026 22:46:04 +0000
Subject: [PATCH] Extract content external request ID helper

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 .../contentexthandler/contentexthandler.go    |  6 +-
 .../contentexthandler_test.go                 | 57 +++++++++++++++++++
 2 files changed, 60 insertions(+), 3 deletions(-)
 create mode 100644 internal/contentexthandler/contentexthandler_test.go

diff --git a/internal/contentexthandler/contentexthandler.go b/internal/contentexthandler/contentexthandler.go
index 37171437e..1622581bc 100644
--- a/internal/contentexthandler/contentexthandler.go
+++ b/internal/contentexthandler/contentexthandler.go
@@ -109,15 +109,15 @@ func (h *Handler[TRequest, TResponse]) DispatchRequest(ctx *workflow.Context, re
 		return ctx.SendMessage("", request)
 	}
 	id := h.requestID(request)
-	req, err := workflow.NewExternalRequest(h.createExternalRequestID(id), h.port, request)
+	req, err := workflow.NewExternalRequest(createExternalRequestID(h.port.ID, id), h.port, request)
 	if err != nil {
 		return err
 	}
 	return ctx.PostRequest(req)
 }
 
-func (h *Handler[TRequest, TResponse]) createExternalRequestID(requestID string) string {
-	return fmt.Sprintf("%d:%s:%s", len(h.port.ID), h.port.ID, requestID)
+func createExternalRequestID(portID, requestID string) string {
+	return fmt.Sprintf("%d:%s:%s", len(portID), portID, requestID)
 }
 
 func (h *Handler[TRequest, TResponse]) Reset() error {
diff --git a/internal/contentexthandler/contentexthandler_test.go b/internal/contentexthandler/contentexthandler_test.go
new file mode 100644
index 000000000..a40389ddf
--- /dev/null
+++ b/internal/contentexthandler/contentexthandler_test.go
@@ -0,0 +1,57 @@
+// Copyright (c) Microsoft. All rights reserved.
+
+package contentexthandler
+
+import (
+	"reflect"
+	"testing"
+
+	"github.com
... (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