[dotnet-port-api] Port message source attribution helpers - #1000
[dotnet-port-api] Port message source attribution helpers#1000Michelle Clayton (michelle-clayton-work) wants to merge 2 commits into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
The helper methods are small, nil-safe, covered by focused unit tests, and the call-site refactors preserve prior behavior while reducing duplication.
Pull request overview
Ports the .NET message-source attribution helper API surface into the Go SDK by adding convenience helpers on message.Message, then refactors existing source-stamping call sites to reuse the new helper. This brings the Go SDK closer to documented API parity without altering the underlying source attribution model.
Changes:
- Added
(*message.Message).SourceType(),SourceID(), andWithSource(...)helpers (nil-safe, clone-on-change behavior). - Refactored context provider, history provider, and middleware source-stamping to use
WithSource. - Updated the .NET↔Go feature comparison matrix to mark source attribution helpers as aligned, and added unit tests for the new helpers.
File summaries
| File | Description |
|---|---|
| agent/context.go | Replaces manual clone-and-stamp logic with msg.WithSource(...) for provided context messages. |
| agent/history.go | Replaces manual clone-and-stamp logic with msg.WithSource(...) for provided history messages. |
| agent/middleware.go | Uses WithSource when stamping middleware-generated messages with an empty source. |
| docs/dotnet-go-sdk-feature-comparison.md | Updates matrix row to reflect the new message.Message source attribution helpers. |
| message/message.go | Introduces SourceType(), SourceID(), and WithSource(...) helper methods on Message. |
| message/message_test.go | Adds tests for default source type behavior and WithSource clone-vs-reuse semantics. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
…ge-source-helpers-c2b406815d117693 # Conflicts: # agent/context.go # agent/history.go # agent/middleware.go # docs/dotnet-go-sdk-feature-comparison.md # message/message.go # message/message_test.go
|
Scope: public API, user-visible behavior Changed Go contract: New exported Upstream evidence reviewed:
Result: aligned. The Go Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
To allow these domains, add them to the network:
allowed:
- defaults
- "github.com"See Network Configuration for more information.
|
Summary
Port the small .NET message-source attribution helper surface to Go by adding
message.Messagehelpers for reading and applying request message source attribution.This change adds
(*message.Message).SourceType(),(*message.Message).SourceID(), and(*message.Message).WithSource(...), then reusesWithSourcein 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:
ad0dac3c86201dc7dc1cd4866ba7e4502a910a0d7dccf3a07bc5fd76004b85305f5121712e188b15Breaking Changes
No.
Tests and Examples
go test ./...message/message_test.gocoverage for default source type, explicit source id/type access, and clone-vs-reuse behavior inWithSourceNotes
docs/dotnet-go-sdk-feature-comparison.mdCloses #761