Repository navigation
.NET: Preserve GitHub Copilot reasoning token usage - #9773
Open
ZedingZhang (ZedingZhang) wants to merge 1 commit into
Open
ZedingZhang (ZedingZhang) wants to merge 1 commit into
ZedingZhang (ZedingZhang) wants to merge 1 commit into
Conversation
ZedingZhang (ZedingZhang)
temporarily deployed
to
github-app-auth
October 27, 2026 18:23 — with
GitHub Actions
Inactive
ZedingZhang (ZedingZhang)
marked this pull request as ready for review
October 27, 2026 18:23
ZedingZhang (ZedingZhang)
temporarily deployed
to
github-app-auth
October 27, 2026 18:23 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The narrow, null-safe mapping preserves zero and missing values, leaves totals unchanged, and has focused regression coverage with no identified defects.
No open issues 🎉
What changed in this PR
Preserves reasoning-token usage reported by the Copilot SDK in the .NET agent adapter, addressing the reasoning-token portion of #9684 without changing other token counts.
Changes:
- Maps the nullable SDK reasoning-token count to
UsageDetails.ReasoningTokenCount. - Adds four regression cases covering positive, zero, missing-counter, and missing-data values while verifying existing counts remain unchanged.
| File | Description |
|---|---|
dotnet/tests/Microsoft.Agents.AI.GitHub.Copilot.UnitTests/GitHubCopilotAgentTests.cs |
Adds reasoning-token preservation regression tests. |
dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs |
Copies reasoning-token usage into response usage details. |
Review effort: Balanced
ZedingZhang (ZedingZhang)
temporarily deployed
to
github-app-auth
October 27, 2026 18:29 — with
GitHub Actions
Inactive
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation & Context
The Copilot SDK reports reasoning-token counts in
AssistantUsageEvent, butGitHubCopilotAgentdrops them when constructingUsageDetails.Description & Review Guide
AssistantUsageData.ReasoningTokensinto the existingUsageDetails.ReasoningTokenCountproperty. Add four offline regression cases for a positive count, zero, a missing counter, and missing usage data.dotnet format --verify-no-changesfor both changed projects. The unit-test run used an English locale and Python 3.12 for unrelated locale-sensitive/Python subprocess tests. Copilot alone has 51 passed and 2 platform/privilege skips.Related Issue
Related to #9684, reasoning-token item only. The broader issue remains open.
N/A - trivial change: this corrects an unambiguous dropped counter by copying an existing SDK property into its existing usage counterpart. It requires no API, representation, or execution-policy decision. No competing open PR for this mapping was found. The issue does not currently carry maintainer implementation approval, so this submission relies on the trivial-change exception.
AI Assistance
AI assistance details: OpenAI Codex assisted with issue analysis, implementation, regression tests, and this PR description. Codex executed the reported build, test, and formatting commands. I reviewed all submitted content and take responsibility for it.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.