Skip to content

[dotnet-port-api] Add message.Source.String formatter - #1320

Merged
Quim Muntal (qmuntal) merged 1 commit into
mainfrom
port-api/source-string-be48438192dab811
Oct 26, 2026
Merged

Quim Muntal (qmuntal) merged 1 commit into
mainfrom
port-api/source-string-be48438192dab811

Conversation

@microsoft-agent-framework-for-go

Copy link
Copy Markdown
Contributor

Summary

Adds message.Source.String() returning <type> or <type>:<id>, with External for the zero source type, mirroring .NET AgentRequestMessageSourceAttribution.ToString() / AgentRequestMessageSourceType.ToString().

Ported .NET PRs

None.

Breaking Changes

None. Source gains a fmt.Stringer method, so %v formatting of a Source now prints the string form instead of the struct fields.

Tests and Examples

Added TestSource_String in message/message_test.go. Ran gofmt, go test ./message/ and go build ./..., all clean. No example changes.

Notes

  • Pinned SHA: 0c9944cc9f577d51277ac7c55dbc388b60a577af. Source: dotnet/src/Microsoft.Agents.AI.Abstractions/AgentRequestMessageSourceAttribution.cs and AgentRequestMessageSourceType.cs.
  • Catalog leaf: Microsoft.Agents.AI / AgentRequestMessageSourceAttribution.ToString() -> string (unmapped). Expected assessment after merge: mapped/adapted to message.Source.String.
  • Screened 128 of 128 gap rows. Only this one group was inspected in depth; GetHashCode is intentionally not ported because Go Source is comparable.
  • Not experimental. Duplicate check: one issue query and one PR query, repeated before publication, both returned 0 results.

Generated by .NET to Go API Porting Agent · copilot · auto · 34.3 AIC · ⌖ 0.681 AIC · ⊞ 13.3K · ◷

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the area:message Changes files in the message area label Oct 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

API consistency review

Result Scope
aligned public API, user-visible behavior

Changed Go contract

New exported method message.Source.String() (fmt.Stringer): returns <type> or <type>:<id>, with External for the zero/external type. %v formatting of Source changes accordingly.

Upstream evidence reviewed

Implementation Source Contract checked
.NET AgentRequestMessageSourceAttribution.ToString {SourceType} or {SourceType}:{SourceId} when the id is non-null
.NET AgentRequestMessageSourceType.Value / ToString Default (unset) value resolves to "External"

Assessment

Go output matches .NET formatting, including the External default for the zero type. The only difference is that Go treats an empty ID as absent, where .NET distinguishes null from empty. This is an idiomatic difference. Python was not consulted because this is a .NET-sourced port with no feature gate.

Generated by Go API Consistency Review Agent for #1320 · copilot · auto · 20.1 AIC · ⌖ 0.611 AIC · ⊞ 12.6K · ◷

@github-actions github-actions Bot added parity-approved Go API consistency review found no parity issues public-api-change Pull Request changes public APIs labels Oct 23, 2026
@qmuntal
Quim Muntal (qmuntal) marked this pull request as ready for review October 26, 2026 09:04
@qmuntal
Quim Muntal (qmuntal) requested a review from a team as a code owner October 26, 2026 09:04
Copilot AI balanced review requested due to automatic review settings October 26, 2026 09:04

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The small, self-contained implementation matches the documented behavior, with all formatting branches covered and no identified blocking issues.

No open issues 🎉

What changed in this PR

Adds message.Source.String() to provide a readable source attribution format aligned with the .NET formatter.

Changes:

  • Returns <type> or <type>:<id>, using External for the zero source type.
  • Adds tests covering empty and populated IDs for external and custom source types.
File Description
message/​message.go Implements and documents the source formatter.
message/​message_test.go Tests all formatting branches.

Review effort: Balanced

Merged via the queue into main with commit 8b72b99 Oct 26, 2026
24 checks passed
@qmuntal
Quim Muntal (qmuntal) deleted the port-api/source-string-be48438192dab811 branch October 26, 2026 09:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:message Changes files in the message area parity-approved Go API consistency review found no parity issues public-api-change Pull Request changes public APIs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants