Skip to content

Document message.Contents.Usage and message.UsageDetails.Add accessors - #728

Merged
George Adams (gdams) merged 1 commit into
microsoft:mainfrom
PratikDhanaveFork:document-contents-usage-usagedetails-add
Jul 29, 2026
Merged

Document message.Contents.Usage and message.UsageDetails.Add accessors#728
George Adams (gdams) merged 1 commit into
microsoft:mainfrom
PratikDhanaveFork:document-contents-usage-usagedetails-add

Conversation

@PratikDhanave

Copy link
Copy Markdown
Contributor

What

Add doc comments to two exported accessors in message/content.go that were missing them:

  • Contents.Usage() — sums the UsageDetails of every UsageContent in the slice, returning the aggregate token usage.
  • UsageDetails.Add(other) — accumulates other into the receiver, summing each token count field and merging AdditionalCounts.

Why

Both are non-boilerplate exported accessors, yet their documented sibling Contents.Text already carries a doc comment while these two did not. Documenting them keeps the public API surface consistently discoverable via go doc and 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.go reports clean.
  • go doc ./message Contents.Usage and go doc ./message UsageDetails.Add render the new comments.

Copilot AI review requested due to automatic review settings July 24, 2026 03:39
@PratikDhanave
PratikDhanave (PratikDhanave) requested a review from a team as a code owner July 24, 2026 03:39

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.

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 aggregates UsageDetails across all UsageContent entries (returning zero usage when none are present).
  • Added a doc comment for UsageDetails.Add(...) describing its field-wise accumulation behavior and AdditionalCounts merge semantics (including first-use map allocation).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@github-actions

This comment has been minimized.

@github-actions github-actions Bot added the parity-approved Go API consistency review found no parity issues label Jul 24, 2026
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.
@PratikDhanave
PratikDhanave (PratikDhanave) force-pushed the document-contents-usage-usagedetails-add branch from 8162141 to dd7fa5c Compare July 24, 2026 09:30
@github-actions

Copy link
Copy Markdown
Contributor

Parity Review: No Issues Found

This PR adds godoc comments to two already-exported accessors in message/content.go:

  • Contents.Usage() — aggregates UsageDetails across all UsageContent items
  • UsageDetails.Add(other) — accumulates token counts and merges AdditionalCounts

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 parity-approved label is correct.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

Generated by Go API Consistency Review Agent · 24.5 AIC · ⌖ 5.54 AIC · ⊞ 5.9K ·

@gdams
George Adams (gdams) added this pull request to the merge queue Jul 29, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jul 29, 2026
@gdams
George Adams (gdams) added this pull request to the merge queue Jul 29, 2026
Merged via the queue into microsoft:main with commit f86996e Jul 29, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

parity-approved Go API consistency review found no parity issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants