Skip to content

Propagate Copilot usage from SDK to agent session#320897

Merged
dmitrivMS merged 2 commits into
mainfrom
dev/dmitriv/agent-host-per-turn-cost
Jun 11, 2026
Merged

Propagate Copilot usage from SDK to agent session#320897
dmitrivMS merged 2 commits into
mainfrom
dev/dmitriv/agent-host-per-turn-cost

Conversation

@dmitrivMS

@dmitrivMS dmitrivMS commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Fixes #319771
Fixes #315160

@dmitrivMS dmitrivMS requested a review from connor4312 June 11, 2026 05:41
@dmitrivMS dmitrivMS self-assigned this Jun 11, 2026
Copilot AI review requested due to automatic review settings June 11, 2026 05:41
@dmitrivMS dmitrivMS added the agent-host Issues for the agent-host implementation (not the protocol) label Jun 11, 2026
@dmitrivMS dmitrivMS added the UBB Issues related to UBB label Jun 11, 2026
@dmitrivMS dmitrivMS enabled auto-merge (squash) June 11, 2026 05:43

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 propagates Copilot credit usage (from the Copilot SDK’s runtime-only copilotUsage field) into Agent Host session usage metadata so the agent sessions UI can display accurate per-turn AIC/credit cost instead of falling back to the coarse cost value.

Changes:

  • Accumulate copilotUsage.totalNanoAiu across assistant.usage events within a turn and attach it to UsageInfo._meta.copilotUsage.
  • Reset the per-turn Copilot usage accumulator when starting/resetting a turn.
  • Extend the CopilotAgentSession unit test to assert cumulative copilotUsage metadata across multiple usage events.
Show a summary per file
File Description
src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts Tracks and emits cumulative per-turn copilotUsage.totalNanoAiu via usage _meta so downstream UI can compute credits accurately.
src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts Adds coverage verifying that copilotUsage metadata is emitted and accumulated across usage events.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 3

Comment thread src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts Outdated
Comment thread src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts Outdated
Comment thread src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts Outdated
@dmitrivMS dmitrivMS requested a review from DonJayamanne June 11, 2026 05:47
@dmitrivMS dmitrivMS requested a review from roblourens June 11, 2026 06:52
@dmitrivMS dmitrivMS moved this to In Progress in Agent Host Protocol Jun 11, 2026
@dmitrivMS dmitrivMS merged commit f72c41f into main Jun 11, 2026
53 of 55 checks passed
@dmitrivMS dmitrivMS deleted the dev/dmitriv/agent-host-per-turn-cost branch June 11, 2026 16:34
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Agent Host Protocol Jun 11, 2026
@vs-code-engineering vs-code-engineering Bot added this to the 1.125.0 milestone Jun 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-host Issues for the agent-host implementation (not the protocol) UBB Issues related to UBB

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Copilot CLI AHP doesnt correctly report per turn AIC cost AgentHost: Show credit usage info

3 participants