Skip to content

GitHub Copilot

Token Optimizer supports GitHub Copilot through an adapter that tracks cost in Copilot’s own AI Credits, scores session quality, and restores continuity. What works depends on your Copilot CLI version, because the adapter reads a capability map and only activates a feature once the hook it needs is confirmed working upstream.

Copilot CLI and Copilot in VS Code share one adapter. They are separate session populations and are never merged, because the two surfaces record different data.

Install from the Copilot (CLI) or Copilot (VS Code) page. The cross-platform grid is at /reference/capability-matrix/.

Each surface has its own authoritative cost source. The adapter uses Copilot’s own figures, never a token estimate.

SurfaceCost figureSource
CLItotalPremiumRequestssession.shutdown event
VS Codeper-request copilotUsageNanoAiudebug-log main.jsonl

VS Code is the more precise surface for cost, because it records a credit figure per request. The CLI only persists an aggregate at shutdown. Per-request token counts on the CLI are never written to disk; usage events are marked ephemeral and only the shutdown aggregate survives.

Two rates are configurable. See the configuration reference for TOKEN_OPTIMIZER_COPILOT_USD_PER_CREDIT and TOKEN_OPTIMIZER_COPILOT_PREMIUM_RATE.

The adapter ships a capability map keyed to Copilot CLI versions. A feature turns on only when the hook it needs is confirmed on your installed version.

Hook powerStatusFeature it gates
permissionDecision deny/allowWorksApproval suppression
updatedInput on preToolUseWorks on supported versionsBash output compression
additionalContext on sessionStartWorksContinuity restore
additionalContext on postToolUseWorks on supported versionsContext-growth nudges
additionalContext on preToolUseBroken upstream, issue #2585 openRead interception, deferred
additionalContext on userPromptSubmittedRegressed upstream, issue #3727 openPer-prompt quality steering, deferred

When an upstream fix lands before the shipped map catches up, override it with TOKEN_OPTIMIZER_COPILOT_CAPS_JSON. See the configuration reference.

Some Copilot internals are never exposed to a companion, so these cannot be approximated.

GapReason
Per-request CLI token countsUsage events are ephemeral; only session.shutdown aggregates persist
Compaction steeringCompaction is server-side, with no injection point
Tool-output substitutionNo updatedOutput on postToolUse
Live fill ringIn-memory only, never persisted
Keep-Warm automationNot available
Status line quality barNo terminal hook surface for a status line

A crash-killed CLI session never writes its shutdown totals. The postToolUse hook keeps an in-flight tally, and rollup recovers that partial data flagged as ~est.. Partial data is never silently dropped and never silently presented as exact.

Every Copilot command needs the runtime prefix.

Terminal window
cd ~/.claude/skills/token-optimizer/scripts
TOKEN_OPTIMIZER_RUNTIME=copilot python3 measure.py copilot-summary

On Windows use python, not python3.

Terminal window
cd ~/.claude/skills/token-optimizer/scripts
TOKEN_OPTIMIZER_RUNTIME=copilot python3 measure.py copilot-doctor

copilot-doctor names which data source is active for each surface and shows capability freshness for your installed CLI version.

The Copilot daemon port is 24845. Whether setup-daemon is wired for Copilot is not documented in the Copilot sources; the shared engine assigns the port. (verify)