Skip to content

[dotnet-port-api] Port message source attribution helpers #761

Description

@github-actions

Summary

Port the small .NET message-source attribution helper surface to Go by adding message.Message helpers for reading and applying request message source attribution.

This change adds (*message.Message).SourceType(), (*message.Message).SourceID(), and (*message.Message).WithSource(...), then reuses WithSource in the context-provider, history-provider, and middleware source-stamping paths. It also updates the feature comparison matrix to mark this helper surface as aligned.

Ported .NET PRs

Relevant upstream commits:

  • ad0dac3c86201dc7dc1cd4866ba7e4502a910a0d
  • 7dccf3a07bc5fd76004b85305f5121712e188b15

Breaking Changes

No.

Tests and Examples

  • go test ./...
  • Added message/message_test.go coverage for default source type, explicit source id/type access, and clone-vs-reuse behavior in WithSource
  • No example changes were needed because the underlying source attribution workflow already existed; this PR ports the missing helper API surface

Notes

  • This is a narrow API-parity PR focused on the helper surface called out in docs/dotnet-go-sdk-feature-comparison.md
  • Broader history-provider reducer-trigger parity remains out of scope for this PR

Generated by .NET to Go API Porting Agent · 1.2K AIC · ⌖ 24.1 AIC · ⊞ 21.7K ·


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-port-api-message-source-helpers-c2b406815d117693.

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 (185 of 185 lines)
From b502c38be66ea9315c3b34a84d03e83b82154209 Mon Sep 17 00:00:00 2001
From: "github-actions[bot]" <github-actions[bot]@users.noreply.github.com>
Date: Tue, 28 Jul 2026 06:25:28 +0000
Subject: [PATCH] [dotnet-port-api] Port message source attribution helpers

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---
 agent/context.go                         |  7 +---
 agent/history.go                         |  7 +---
 agent/middleware.go                      |  4 +-
 docs/dotnet-go-sdk-feature-comparison.md |  2 +-
 message/message.go                       | 31 ++++++++++++++
 message/message_test.go                  | 52 ++++++++++++++++++++++++
 6 files changed, 87 insertions(+), 16 deletions(-)

diff --git a/agent/context.go b/agent/context.go
index 40c3baa58..5d8c144ea 100644
--- a/agent/context.go
+++ b/agent/context.go
@@ -135,12 +135,7 @@ func (p *defaultContextProvider) Invoking(ctx context.Context, invoking Invoking
 	if len(providedMessages) > 0 {
 		source := message.Source{Type: SourceTypeContextProvider, ID: p.config.SourceID}
 		for i, msg := range providedMessages {
-			if msg == nil || msg.Source == source {
-				continue
-			}
-			marked := msg.Clone()
-			marked.Source = source
-			providedMessages[i] = marked
+			providedMessages[i] = msg.WithSource(source)
 		}
 		outMessages = append(outMessages, providedMessages...)
 	}
diff --git a/agent/history.go b/agent/history.go
index 348175eb6..ef92fa038 100644
--- a/agent/history.go
+++ b/agent/history.go
@@ -109,12 +109,7 @@ func (p *defaultHistoryProvider) Invoking(ctx context.Context, invoking Invoking
 
 	source := message.Source{Type: SourceTypeHistoryProvider, ID: p.config.SourceID}
 	for i, msg := range providedMessages {
-		if msg == nil || msg.Source == source {
-			continue
-		}
-		marked := msg.Clone()
-		marked.Source = source
-		providedMessages[i] = marked
+		providedMessages[i] = msg.WithSource(source)
 	}
 	outMessages := append(providedMessages, invoking.Messages...)
 
d
... (truncated)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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