Foundry Toolkit Copilot model provider drops token usage and always reports zero context tokens
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- github, javascript, vscode
調査の方向性
The report identifies provideTokenCount() and provideLanguageModelResponse in the bundled dist/extension.js, and mentions convertOpenAIChunkToChatChunk as the usage conversion point. Start by locating these in the unminified extension source and tracing how response chunks reach Copilot. Done means actual input, output, and cached token usage is forwarded and token counting no longer always returns zero; the issue names no tests to run.
索引モデルが issue の本文から書いたものです。
説明
Title: Foundry Toolkit Copilot model provider drops token usage and always reports zero context tokens
Environment
- VS Code: 1.142.0
- Integrated Copilot extension: 0.70.0
- Microsoft Foundry Toolkit: 1.6.19
- OS: Windows x64
- Model: Azure Foundry deployment
gpt-5.6-sol - Integration: Foundry Toolkit language model provider in VS Code Copilot Chat
Problem
When using an Azure Foundry model through Foundry Toolkit in GitHub Copilot Chat, token usage is not reported correctly.
Observed behavior:
- Context window indicator always displays
0 / 1M tokens. - Agent Debug Logs report 0 input and output tokens.
- Copilot
/usagereports AI Units but no Azure API token usage. - OpenTelemetry file export is enabled, but no chat token usage metrics are recorded.
Azure Foundry itself processes and bills the model requests normally. A separate direct API test confirms that the service returns valid usage information, including prompt_tokens, completion_tokens, and total_tokens.
Root cause identified through local extension analysis
1. Token counting always returns zero
In the installed Foundry Toolkit bundle:
dist/extension.js, around line 2520:
async provideTokenCount(i,a,o){return 0}
This explains why the Copilot context window indicator always displays zero.
2. API usage is not forwarded to Copilot
The internal response conversion handles the API usage information:
convertOpenAIChunkToChatChunk, around line 4988.
However, the language model provider implementation:
provideLanguageModelResponse, around line 2517
appears to forward text and tool-call content without forwarding the token usage data.
In the integrated Copilot extension, around line 7013, the consumer expects usage information as a LanguageModelDataPart. When it is missing, input, output, and cache token counts are set to zero.
These findings are based on inspection of the installed, bundled JavaScript code and have not been independently validated against the unminified source.
Expected behavior
- Forward actual API input, output, and cached token usage to VS Code Copilot.
- Implement meaningful token counting instead of returning zero.
- Make token usage available to the Agent Debug Logs and supported telemetry consumers.
- Allow developers using Azure Foundry BYOK deployments to monitor token consumption per model request.
Additional observation
OpenTelemetry file export works and produces telemetry data, but the inspected file contains no model-request token usage metrics. The missing model-turn spans may require separate investigation.
Impact
Without reliable token reporting, developers cannot monitor or optimize API token consumption within Copilot Chat.
In our environment, 296 Azure requests consumed approximately 3.28 million tokens, while the Copilot UI continued displaying zero usage.
Request
Could you confirm whether forwarding token usage from Foundry Toolkit language model providers to Copilot is currently supported?
If supported, please investigate the missing usage forwarding and the provideTokenCount() implementation.
If not yet supported, please consider implementing it so that users of Azure Foundry BYOK models can monitor their actual token consumption.
- 主要言語
- JavaScript
- スター
- 2.1k
- フォーク
- 260
- 平均マージ
- 3時間 18分
- マージ済み PR(30日)
- 43
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/foundry-dev-tools のほかの issue
-
I can not deploy it.オープンneeds attention
難易度 3/5 半日 初心者へのやさしさ 34/100
microsoft/foundry-dev-tools#944 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
needs attention
難易度 3/5 1〜2日 初心者へのやさしさ 56/100
microsoft/foundry-dev-tools#943 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
needs attention
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
microsoft/foundry-dev-tools#942 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Foundry Toolkit: GPT-6 luna tool calls fail in VS Code Chat because Chat Completions is used with reasoning対応中かも @a1exwang が 3 日前に担当しました。 オープンneeds attention
難易度 3/5 1〜2日 初心者へのやさしさ 70/100
microsoft/foundry-dev-tools#924 · コメント 3 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
error while deploying model対応中かも @JerryYangKai が 10 日前に担当しました。 オープンinvestigating
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
microsoft/foundry-dev-tools#899 · コメント 2 件 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
microsoft/foundry-dev-tools の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
obsidianmd/obsidian-developer-docs#281 ·
メンテナーはふだん 4 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
FriendsOfFlarum/synopsis#16 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Fei-Away/Codex-Dream-Skin#449 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
sysprog21/codetrial#604 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
outline/outline#14489 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信