Document message.Contents.Usage and message.UsageDetails.Add accessors - #728
Conversation
There was a problem hiding this comment.
Pull request overview
This PR improves the public message package API documentation by adding missing Go doc comments for two exported accessors related to token-usage aggregation, aligning their discoverability and described semantics with the existing documented accessors.
Changes:
- Added a doc comment for
Contents.Usage()describing that it aggregatesUsageDetailsacross allUsageContententries (returning zero usage when none are present). - Added a doc comment for
UsageDetails.Add(...)describing its field-wise accumulation behavior andAdditionalCountsmerge semantics (including first-use map allocation).
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This comment has been minimized.
This comment has been minimized.
Add doc comments to the two exported usage accessors in message/content.go that lacked them, matching the documented sibling Contents.Text. Clarifies that Contents.Usage aggregates token usage across UsageContent entries and that UsageDetails.Add accumulates and merges into the receiver.
8162141 to
dd7fa5c
Compare
Parity Review: No Issues FoundThis PR adds godoc comments to two already-exported accessors in
This is a docs-only change (1 file, 2 added comment lines, zero behavioral change). No exported API surface was added, removed, or altered. Cross-repo parity: The semantics (summing token-count fields, merging additional counts) are consistent with the upstream .NET/Python usage aggregation pattern. Documenting them keeps the Go public API discoverable and aligned with how the cross-SDK behavior contract is described in other languages. Verdict: ✅ No parity issues. The Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "awmgmcpg"See Network Configuration for more information.
|
What
Add doc comments to two exported accessors in
message/content.gothat were missing them:Contents.Usage()— sums theUsageDetailsof everyUsageContentin the slice, returning the aggregate token usage.UsageDetails.Add(other)— accumulatesotherinto the receiver, summing each token count field and mergingAdditionalCounts.Why
Both are non-boilerplate exported accessors, yet their documented sibling
Contents.Textalready carries a doc comment while these two did not. Documenting them keeps the public API surface consistently discoverable viago docand godoc. These accessors are the Go equivalents of the .NET/Python usage aggregation helpers (UsageDetails.Add / usage summing over content), so documenting their aggregation-and-merge semantics aligns the Go port's public docs with the cross-SDK behavior contract.Testing
Docs-only change; no behavioral change. Verified with:
go build ./...,go vet ./message/...,go test ./message/...all pass.gofmt -l message/content.goreports clean.go doc ./message Contents.Usageandgo doc ./message UsageDetails.Addrender the new comments.