microsoft / microsoft/vscode-documentdb

Surface credits used in AI Performance Insights byline (blocked on VS Code LM pricing API)

Open
#689 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

on-hold
Dominant language
TypeScript
Stars
31
Forks
22
Avg merge
2d 20h
Merged PRs (30d)
21

Description

Summary

In the Query Insights AI Performance Insights panel we want to surface the number of GitHub Copilot credits consumed by each AI run, alongside the existing utility model disclosure. Users care far more about "credits used" than about raw token counts, and surfacing the cost honestly is a key part of the cost neutral disclosure we ship today.

This work is currently blocked by VS Code platform work: the stable Language Model API does not expose pricing or per request cost data to extensions, and this extension intentionally avoids proposed / preview APIs.

Motivation

  • Today the post-response byline reads, in effect: "Powered by gpt-4o via GitHub Copilot, a utility model intended to be cost neutral for GitHub Copilot subscribers. Learn more".
  • We want to add an actual credits figure (for example "0.3 credits used" or "1 credit used") so the disclosure is verifiable rather than aspirational, mirroring the per turn credits footer the built in Copilot chat already shows.
  • We already capture and report best effort token usage internally (in the trace output and in telemetry), but tokens are debug level information. The cost as the user understands it is credits.

What we tried

  1. The stable vscode.LanguageModelChat interface (in @types/vscode/index.d.ts) only exposes name, id, vendor, family, version, and maxInputTokens. There is no pricing, no per request cost, no credits used reporting, and no usage object on LanguageModelChatResponse.
  2. The proposed API vscode.proposed.languageModelPricing.d.ts adds pricing, inputCost, outputCost, cacheCost, priceCategory, and long context variants on LanguageModelChat and LanguageModelChatInformation. We intentionally do not consume proposed APIs in this extension.
  3. Internally VS Code already plumbs richer data:
    • ILanguageModelChatMetadata in src/vs/workbench/contrib/chat/common/languageModels.ts carries the same pricing fields.
    • IChatQuotaService.getCreditsForTurn(...) and copilot_usage.total_nano_aiu (see extensions/copilot/src/extension/prompt/node/chatMLFetcher.ts and extensions/copilot/src/platform/chat/common/chatQuotaServiceImpl.ts) already track per turn credits inside the Copilot extension.
    • None of this is reachable from a third party extension on stable APIs.
  4. As a diagnostic we already JSON dump the selected model's own enumerable properties to the trace output. That dump is purely observational and does not depend on any proposed field.

Acceptance criteria

This issue can be closed when at least one of the following is available on stable VS Code APIs and integrated into the AI Performance Insights flow:

  • A per request credits value reported back from LanguageModelChat.sendRequest(...) (in spirit equivalent to today's copilot_usage.total_nano_aiu), or
  • Stable pricing metadata on LanguageModelChat (equivalent to today's pricing, inputCost, outputCost, cacheCost, priceCategory) so the extension can compute an estimate using its existing token counts.

Once available, update the post-response byline in QueryInsightsTab.tsx to render the credits figure next to the model name, using the same formatting style as VS Code's footer: integer values as is, non integer values to one decimal place (for example "0.3 credits", "1 credit", "5 credits").

Blocking work in microsoft/vscode

  • microsoft/vscode#252230 ("Meta: Consumptive billing model") is the umbrella tracking issue for the consumptive billing experience.
  • The proposed pricing API lives in src/vscode-dts/vscode.proposed.languageModelPricing.d.ts and is not yet finalised. The d.ts file's own header tracking link is a placeholder (// https://github.com/microsoft/vscode/issues/XXXXX).

Workaround until the API is available

Until pricing or credits land on a stable API:

  • The byline shows the model id and the cost neutral disclosure without a credits figure.
  • Token usage stays in the trace output (compact format via formatTokenCount) and in telemetry only.
  • The copilot-utility fallback in FALLBACK_MODELS keeps us on a model that the Copilot side considers cost neutral, even if gpt-4o and gpt-4o-mini change.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read QueryInsightsTab.tsx and the stable LanguageModelChat definitions in @types/vscode/index.d.ts, then review the referenced pricing proposal and Copilot quota files. The issue is done when stable VS Code APIs expose per-request credits or pricing metadata and the AI Performance Insights byline renders the formatted credits value alongside the model name.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
developer-experience, tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.