Copilot Cost & Token Tracker
Visualise Copilot agent session token costs directly inside VS Code. The extension runs locally, reads agent debug logs from your workspace storage, and shows live session insights, deep-dive analysis, pricing diagnostics, and exportable cost data without sending anything off-machine.
What’s new
The current release adds a much richer dashboard experience, including:
- A full per-session Analysis view with turn-by-turn breakdowns, tool and agent detail, cache events, and model-level cost details
- Deep Dive access for sessions with debug logs, including turn-by-turn request and tool analysis
- Focused-session star support so you can build a watchlist of important sessions and filter to just those in the All Sessions view
- CSV and JSON export for the currently selected view or focused-session subset
- Daily usage charts in the Aggregate view, with Overall, By Model, and By Space modes, including multi-select series filtering
- Improved pricing support with remote refresh, manual update controls, and pricing diagnostics for observed vs. known models
- Better cache-stability analysis with clearer unavailable-state handling for CLI and chat-only sessions
- A Models view for inspecting bundled and refreshed pricing data, including model matching and pricing status
Features
Dashboard views
- Latest Session — a live per-model breakdown of your most recent Copilot agent session; it refreshes while the session is active
- All Sessions — a sortable table of sessions with cost, credit, token, and cache indicators; click any row to inspect details inline
- Aggregate — rolled-up totals across the selected time window, broken down by model, workspace, and day
- Models — inspect the models recognized by the pricing table, their providers, rates, and pricing coverage/status
Analysis and deep dive
- Turn-by-turn analysis for supported sessions with expandable/collapsible detail blocks
- Call-level information for model, tokens, cache usage, and cost
- Sub-agent call detection with badges for main-agent vs. sub-agent LLM calls
- Automatic-mode recognition with the applicable 10% cost discount shown in session and model details
- Deep Dive access for sessions with available debug logs
Session management
- Star/focus sessions to build a watchlist of important sessions
- Filter the All Sessions view to focused sessions only
- Filter session lists by workspace
- Export the current view as CSV or JSON, including focused-session and workspace-filtered exports
Cost, tokens, and cache insights
- USD cost and AI Credits (1 credit = $0.01) totals for sessions and aggregate views
- Include or exclude built-in sub-agent costs from displayed totals with the dashboard toggle
- Per-model token breakdown for fresh input, cached input, cache writes, and output tokens
- Cache hit rate and cache-stability metrics for models with supported turn-level samples
- Clear handling for CLI and chat-only sessions when cache behavior cannot be computed
Time windows and pricing
- Preset time windows: 6 h, 12 h, 24 h, 48 h, 72 h, 7 days, 30 days, and month-to-date
- Custom date-range picker for any arbitrary period
- Daily usage chart modes for overall usage, usage by model, and usage by workspace, with selectable series and clear-selection controls
- Bundled pricing table with model-key matching and pricing diagnostics
- Automatic or manual pricing refresh from the configured pricing source
Privacy and portability
- Reads only local Copilot agent debug logs from VS Code / VS Code Insiders workspace storage
- Cross-platform support for macOS, Windows, and Linux storage paths
- No dashboard data leaves your machine
Requirements
- VS Code 1.85 or later, or VS Code Insiders
- Existing Copilot agent session logs in your local workspace storage
Installation
From the Marketplace
- Open the Extensions view in VS Code
- Search for Copilot Cost & Token Tracker
- Install the extension
- Reload when prompted
From a VSIX
- Download the .vsix file
- Open the Extensions view
- Select ... and choose Install from VSIX...
- Pick the downloaded .vsix file
- Reload when prompted
Usage
Open the dashboard with any of these entry points:
- Status bar: Token Cost
- Activity bar: Token Cost Tracker
- Command Palette: Copilot Cost & Token Tracker: Open Dashboard
Use the time-window dropdown to switch between the built-in windows, or pick a custom range. The dashboard can include or exclude built-in sub-agent costs, which are tracked separately. In the All Sessions view, sort by a column, filter by workspace, star sessions to keep a focused watchlist, and export the resulting set when needed. In Aggregate, switch daily usage between overall, model, and workspace views and select the series to compare.
Commands
| Command |
Description |
| Copilot Cost & Token Tracker: Open Dashboard |
Open the dashboard webview |
| Copilot Cost & Token Tracker: Reset Anonymous User ID |
Reset the extension’s anonymous local user identifier |
| Copilot Cost & Token Tracker: Update Pricing Data Now |
Refresh pricing data immediately |
Settings
| Setting |
Default |
Description |
| copilotCost.pricing.autoUpdate |
true |
Automatically re-check the remote pricing source periodically |
| copilotCost.pricing.updateIntervalHours |
24 |
How often (hours) to re-check pricing. Range 1–168 |
| copilotCost.pricing.sourceUrl |
GitHub docs YAML |
URL to fetch model pricing data from |
| copilotCost.pricing.sourceFormat |
github-docs-yaml |
Format of the pricing source |
| copilotCost.cacheBehavior.dropThresholdTokens |
4096 |
Minimum cached-token drop used to detect a cache reset |
Changing copilotCost.cacheBehavior.* settings immediately invalidates persisted session caches and re-analyses sessions with the new settings when the dashboard next loads.
Privacy
- Reads only local Copilot agent debug logs
- Does not send data to an external service
- Unknown or unpriced models are flagged in the dashboard and excluded from totals where appropriate
How it works
The extension scans local VS Code and VS Code Insiders workspace storage directories, finds Copilot agent debug-log sessions, parses the JSONL data, and computes token usage and cost totals locally.
Model coverage
The bundled pricing table covers the major Copilot model families used by the extension. If a model is not present in media/pricing.json, it is shown with a warning and excluded from totals where pricing is unavailable.
Troubleshooting
- If the dashboard is empty, make sure you have an existing Copilot agent or Copilot CLI session and that the relevant local session logs exist.
- If a model is missing pricing data, it will be shown with a warning and its cost will be excluded.
- If pricing data looks stale, use the Update Pricing Data Now command or adjust the pricing settings.
- Copilot CLI sessions provide aggregate shutdown metrics only; per-request Analysis and per-turn cache tracking may be unavailable when the CLI log does not persist usage events.
Limitations
- Per-turn CLI cache data is conditional — the parser supports persisted assistant.usage events when a CLI log contains them, but common CLI logs may not record them. In those cases the dashboard marks cache tracking as unavailable rather than implying a zero-break result.
- Copilot CLI sessions do not provide the same per-request detail as VS Code agent sessions, so Analysis and Deep Dive are limited or unavailable for CLI-only logs.
- TTL classification is heuristic — the dashboard labels some cache drops as likely TTL expiry based on known provider timing windows, but the logs do not report the actual eviction reason.
- Unknown providers receive threshold-based reset detection but no vendor-specific TTL classification.
- Cache stability is computed per session and is not compared across sessions.
Development
npm install
npm run compile
npm run package
License
MIT
| |