Skip to content

Add per turn info for CLIs as well#315152

Merged
pwang347 merged 6 commits intomainfrom
pawang/cliPerTurnCredits
May 8, 2026
Merged

Add per turn info for CLIs as well#315152
pwang347 merged 6 commits intomainfrom
pawang/cliPerTurnCredits

Conversation

@pwang347
Copy link
Copy Markdown
Member

@pwang347 pwang347 commented May 8, 2026

Related #314813

Copilot AI review requested due to automatic review settings May 8, 2026 01:41
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

Screenshot Changes

Base: bea36d2f Current: 3741958c

Changed (2)

agentSessionsViewer/ClaudeProvider/Dark
Before After
before after
agentSessionsViewer/ClaudeProvider/Light
Before After
before after

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 extends per-turn model footer details for Copilot CLI and Claude-backed chat sessions by tracking turn-scoped credit usage and surfacing it in ChatResult.details, aligning CLI flows more closely with existing per-turn quota tracking used elsewhere in the Copilot extension.

Changes:

  • Add optional per-turn “credits used” formatting to CLI/Claude response footer details.
  • Wire IChatQuotaService into CLI session participants and the Copilot CLI SDK session to accumulate/reset turn credits.
  • Add turnId tracking to Claude session state and forward it into Claude proxy requests so chatMLFetcher can attribute usage to the correct turn.
Show a summary per file
File Description
extensions/copilot/src/extension/chatSessions/vscode-node/copilotCLIModelDetails.ts Adds optional credits-based details formatting and updates return shape to use computed details.
extensions/copilot/src/extension/chatSessions/vscode-node/copilotCLIChatSessionsContribution.ts Injects IChatQuotaService, passes turn credits into model details, and resets credits in finally.
extensions/copilot/src/extension/chatSessions/vscode-node/copilotCLIChatSessions.ts Injects IChatQuotaService, passes turn credits into model details, and resets credits in finally.
extensions/copilot/src/extension/chatSessions/vscode-node/claudeChatSessionContentProvider.ts Sets/clears per-session turnId and formats details with credits when available.
extensions/copilot/src/extension/chatSessions/copilotcli/node/copilotcliSession.ts Resets turn credits at request start and attempts to accumulate credits from SDK assistant.usage events.
extensions/copilot/src/extension/chatSessions/claude/node/claudeSessionStateService.ts Persists turnId in Claude session state and adds getters/setters.
extensions/copilot/src/extension/chatSessions/claude/node/claudeLanguageModelServer.ts Forwards turnId into Claude proxy requests so downstream usage can be attributed per turn.
extensions/copilot/src/extension/chatSessions/claude/common/claudeSessionStateService.ts Extends the shared session-state contract to include turnId accessors.

Copilot's findings

  • Files reviewed: 8/8 changed files
  • Comments generated: 5

@pwang347 pwang347 marked this pull request as ready for review May 8, 2026 02:24
@pwang347 pwang347 enabled auto-merge (squash) May 8, 2026 02:24
Copy link
Copy Markdown
Member

@TylerLeonhardt TylerLeonhardt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approving for Claude. FYI @DonJayamanne

@pwang347 pwang347 merged commit 4c72b54 into main May 8, 2026
26 checks passed
@pwang347 pwang347 deleted the pawang/cliPerTurnCredits branch May 8, 2026 03:10
@vs-code-engineering vs-code-engineering Bot added this to the 1.120.0 milestone May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants