Skip to content

Comments

Researching actual token usage#203

Merged
rajbos merged 7 commits intomainfrom
actual-tokens
Feb 22, 2026
Merged

Researching actual token usage#203
rajbos merged 7 commits intomainfrom
actual-tokens

Conversation

@rajbos
Copy link
Owner

@rajbos rajbos commented Feb 9, 2026

This pull request enhances the token tracking and reporting features in src/extension.ts by adding support for actual token counts from LLM API usage data, alongside existing text-based estimates. It introduces new fields and interfaces to capture this data, updates aggregation logic to use the most accurate token values available, and improves session log parsing to extract detailed token usage when possible.

Token tracking improvements:

  • Added estimatedTokens and actualTokens fields to PeriodStats, session cache, and usage summaries to distinguish between text-based estimates and actual LLM API-reported token counts. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]

  • Aggregation logic now prefers actual token counts when available, falling back to estimates otherwise, for improved accuracy in usage statistics.

Session log parsing enhancements:

  • Introduced PromptTokenDetail and ActualUsage interfaces to capture detailed prompt token breakdowns and actual usage data from LLM API responses.
  • Updated session log parsing to reconstruct session state for delta-based formats and extract actual token usage per request, including prompt/completion tokens and prompt token details. [1] [2] [3] [4] [5] [6]

Chat turn details:

  • Extended ChatTurn interface and log viewer logic to include actual usage data for each turn, enabling more precise diagnostics and insights. [1] [2] [3]

Cache management:

  • Increased cache version to force rebuild and ensure extraction of actual token usage is applied to all sessions.

These changes collectively improve the accuracy and granularity of token usage reporting, supporting both estimated and actual values for better diagnostics and analytics.

@rajbos rajbos mentioned this pull request Feb 13, 2026
rajbos and others added 5 commits February 22, 2026 20:47
This commit automatically updates src/toolNames.json with new tool
identifiers from microsoft/vscode-copilot-chat repository.

Source: microsoft/vscode-copilot-chat
File: src/extension/tools/common/toolNames.ts
chore: sync toolNames.json with vscode-copilot-chat
@rajbos rajbos marked this pull request as ready for review February 22, 2026 22:11
@rajbos rajbos enabled auto-merge February 22, 2026 22:12
@rajbos rajbos merged commit 5b042b3 into main Feb 22, 2026
12 checks passed
@rajbos rajbos deleted the actual-tokens branch February 22, 2026 22:13
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.

1 participant