Skip to content

feat(usage): GitHub Copilot sessions show in usage history - #27059

Closed
Radu028 wants to merge 4 commits into
pingdotgg:mainfrom
Radu028:feat/copilot-usage-history
Closed

Radu028 wants to merge 4 commits into
pingdotgg:mainfrom
Radu028:feat/copilot-usage-history

Conversation

@Radu028

@Radu028 Radu028 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

GitHub Copilot is missing from Usage. Copilot runs through the ACP Registry driver, and that driver has no usage reader. Copilot CLI sessions therefore never count toward cost, tokens, or the model breakdown. The CLI already writes a usage receipt for every model call to ~/.copilot/session-state/<session>/events.jsonl.

This follows the provider-parity path maintainers set for Pi (#17848) and Muse Code (#22443, invited in #19060). Copilot's plan quota in Limits is a separate request (#22866) and is not part of this PR.

#23380 (Mistral Vibe) also sets the ACP Registry driver's usage reader, and a driver has only one. If both land, the second needs the two readers combined into one that dispatches by agent.

How

  • The ACP Registry driver gets a transcript reader for Copilot CLI session.usage_record events, including subagent calls. It reads ~/.copilot/session-state, or session-state under COPILOT_HOME from the server environment or a Copilot account's environment. Like the other providers' default homes, the host's Copilot home counts even without a configured Copilot account, so Copilot CLI sessions run outside T3 Code count too. Accounts that run other ACP agents add nothing, and homes shared by several accounts count once.
  • Each receipt counts once by its usageId, so a resumed session that replays earlier receipts adds nothing. Copilot's inputTokens includes cache reads and writes, so the reader splits those out. Reasoning tokens are already part of output.
  • Cost is the AI credits Copilot recorded (totalNanoAiu, $0.01 per credit) when aiCreditsStatus is complete, including a complete zero. Partial or missing credits fall back to the github_copilot/<model> price, and BYOK models use the model's own price. The receipt's cost field is a premium-request multiplier, not money, so the reader ignores it.
  • copilot joins the usage provider contract. Web and mobile label it GitHub Copilot with the Copilot icon and Copilot Purple (#8534f3, from GitHub's brand colors). Hiding Copilot in the provider filter leaves other ACP Registry agents' limits visible.
  • The user guide lists the new source and where it reads from.

Before

Usage has no GitHub Copilot entry, and Copilot sessions count nowhere.

Usage provider menu without GitHub Copilot

After

Usage filtered to GitHub Copilot, over 10 real Copilot CLI sessions.

Usage showing GitHub Copilot cost, tokens, and models

Verification

  • copilotUsage.test.ts parses receipts shaped like Copilot CLI 1.0.105 output: main and subagent receipts across a resume, skipped shutdown totals, complete, zero, partial, unavailable, and missing credits, BYOK models, and malformed counters.
  • UsageService.test.ts reads the host home and a Copilot account's COPILOT_HOME once each, skips a non-Copilot account's home, keeps the host home when another agent holds the acpRegistry instance ID, and counts a resumed session's receipts once. The last case fails without the reader's host-ID check.
  • With 748 real receipts from 10 Copilot CLI 1.0.105 sessions (message content stripped), the web Usage page shows $41.62 and 73.6M tokens. An independent sum of the same receipts gives $41.619406565.
  • vp run check:changed passes.

Not checked: Copilot CLI versions before 1.0.105, and the mobile Usage screen on a device. Not supported: the legacy --config-dir flag in an account's launch arguments. GitHub recommends COPILOT_HOME, which works per account.

Implemented with Claude Opus 5.5 in Claude Code, running in T3 Code. Reviewed with GPT 6.1 Sol in Codex.

🤖 Generated with Claude Code

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Oct 29, 2026
@macroscopeapp

macroscopeapp Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Needs Human Approval

Macroscope's review found this PR requires human approval — Copilot history is now automatically included in usage summaries, even without a configured Copilot account. Human review must confirm this default expansion of history coverage and displayed costs.

Needs human approval because:

  • Macroscope's correctness review did not reach a verdict

Notes:

  • The correctness review was unavailable. Eligibility was assessed without its result.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration
Commits

Reviewing files that changed from the base of the PR and between 618f1fd and 8d4dae5.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between fa4f3a2 and 618f1fd.

Files selected for processing: 16
  • apps/mobile/src/features/usage/usageProviders.ts
  • apps/server/src/provider/builtInDrivers.ts
  • apps/server/src/usage/UsageService.test.ts
  • apps/web/src/components/usage/UsageLimits.tsx
  • apps/web/src/components/usage/UsageModelDialog.tsx
  • apps/web/src/components/usage/UsagePage.tsx
  • apps/web/src/components/usage/UsageProviderChart.test.ts
  • apps/web/src/components/usage/UsageProviderChart.tsx
  • apps/web/src/components/usage/usageProviders.ts
  • docs/user/usage.md
  • packages/contracts/src/usage.ts
  • packages/provider-acp-registry/src/server/adapter.ts
  • packages/provider-acp-registry/src/server/copilotAcp.ts
  • packages/provider-acp-registry/src/server/copilotUsage.test.ts
  • packages/provider-acp-registry/src/server/copilotUsage.ts
  • packages/provider-acp-registry/src/server/driver.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

Walkthrough

The change adds GitHub Copilot usage history from CLI session receipts. It registers a reader with the ACP Registry driver, adds Copilot to usage provider contracts and presentation, and documents the session sources and recorded credit costs.

Changes: GitHub Copilot usage history

Layer / File(s) Summary
Copilot provider identity
packages/contracts/src/usage.ts, packages/provider-acp-registry/src/server/copilotAcp.ts, packages/provider-acp-registry/src/server/adapter.ts, apps/web/src/components/usage/usageProviders.ts, apps/mobile/src/features/usage/usageProviders.ts
The usage provider contract and presentation include Copilot. ACP Registry Copilot detection uses isCopilotAgent, which checks local command names or the registry agent ID.
Parse Copilot session receipts
packages/provider-acp-registry/src/server/copilotUsage.ts, packages/provider-acp-registry/src/server/copilotUsage.test.ts
The reader scans Copilot session-state event files and parses usage receipts. It validates token values, deduplicates usage identities, and reports costs when complete credit data is available. Tests cover resumed sessions, subagents, BYOK, and malformed or incomplete receipts.
Register the usage reader
packages/provider-acp-registry/src/server/driver.ts, apps/server/src/provider/builtInDrivers.ts, apps/server/src/usage/UsageService.test.ts
The ACP Registry driver uses the Copilot reader, and the server includes the driver in its built-in usage drivers. The service test covers configured and host Copilot histories, resumed sessions, and subagent receipts.
Present Copilot usage
apps/web/src/components/usage/UsageLimits.tsx, apps/web/src/components/usage/UsageModelDialog.tsx, apps/web/src/components/usage/UsagePage.tsx, apps/web/src/components/usage/UsageProviderChart.tsx, apps/web/src/components/usage/UsageProviderChart.test.ts, apps/mobile/src/features/usage/usageProviders.ts, docs/user/usage.md
Usage views pass ACP Registry agent IDs to provider icons, and hidden ACP Registry providers are handled separately when filtering limits. Mobile provider labels and colors, chart expectations, and usage documentation include Copilot. The documentation describes session sources and the recorded AI-credit cost.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant AcpRegistryDriver
  participant copilotUsageReader
  participant CopilotSessionStateFiles
  participant copilotUsageFormat
  AcpRegistryDriver->>copilotUsageReader: Configure usage reader
  copilotUsageReader->>CopilotSessionStateFiles: Scan session-state event files
  CopilotSessionStateFiles-->>copilotUsageReader: Return event lines
  copilotUsageReader->>copilotUsageFormat: Parse receipt events
  copilotUsageFormat-->>copilotUsageReader: Return usage records
Loading

Possibly related PRs

  • pingdotgg/t3code#10409: Adds the usage-history reader framework and ACP Registry integration extended here for Copilot.
  • pingdotgg/t3code#23380: Adds another ACP Registry session-history reader through the usage-reader contract.

Suggested reviewers: maria-rcks, juliusmarminge, wiktor102

Merge Risk: Minimal · previous review 618f1

No confirmed issue prevents merging after normal checks.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Description check Inconclusive The description states the problem (GitHub Copilot sessions are missing from Usage because the ACP Registry driver has no usage reader), the change (a transcript reader for Copilot CLI `session.usage_… Add a link to the triaged issue or discussion that gives explicit maintainer approval for adding Copilot usage. Include the approval comment. The description cites #17848, #22443, and #19060 as parity precedent, but these do not show approv…
Passed Passed checks: 3 passed
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: adding GitHub Copilot sessions to usage history.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description states the problem (GitHub Copilot sessions are missing from Usage because the ACP Registry driver has no usage reader), the change (a transcript reader for Copilot CLI session.usage_record events, copilot added to the provider contract, web and mobile labels and colors, and a user guide update), and the scope (Copilot plan quota is excluded). It also includes the required Verification details: named test files with covered cases, a reported total checked against an independent sum, vp run check:changed passing, and unchecked items. The Before/After screenshots cover the UI change. The template's Scope and approval section is only partly satisfied. It cites prior maintainer-approved provider-parity paths (#17848, #22443, #19060) and a related issue (#22866), but it does not link a triaged bug issue or explicit maintainer approval for this specific change. The title is not in the description body, so the conventional-commit title is not checked here.

Resolution

Add a link to the triaged issue or discussion that gives explicit maintainer approval for adding Copilot usage. Include the approval comment. The description cites #17848, #22443, and #19060 as parity precedent, but these do not show approval for this change. Confirm that the PR title follows the conventional commit format from the template.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

Radu028 and others added 4 commits October 30, 2026 06:36
Usage read local history for every provider except Copilot, so Copilot
calls made through T3 or the Copilot CLI were missing from tokens, cost,
the hourly chart, and the model breakdown.

The ACP Registry driver now reads Copilot CLI's
session-state/<id>/events.jsonl from ~/.copilot or COPILOT_HOME, for the
host and for each Copilot instance; other registry agents contribute
nothing. Only durable session.usage_record receipts count. Shutdown totals
overlap them. Input tokens include cache reads and writes, and subagent
receipts keep their own model under the parent session. Each model call is
deduplicated by a digest of its accounting usageId, so a call re-appended
after a resume counts once. Cost is Copilot's recorded nano-AIU at $0.01
per AI credit when the credits are complete, otherwise model rates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot reports complete AI-credit accounting including explicit zeros,
so a complete receipt with no charge is not an unknown cost to price by
model.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ost Copilot history

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Radu028
Radu028 force-pushed the feat/copilot-usage-history branch from 618f1fd to 8d4dae5 Compare October 30, 2026 04:37
@t3-code-bot

t3-code-bot Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

closing at @StiensWout's request under Establish the problem and scope first.

This adds a new GitHub Copilot native-history reader and usage provider, including credit billing interpretation, default host-history discovery, deduplication and web/mobile presentation. The cited Pi and Muse PRs are approval for those providers, not Copilot. Full issue 19060 explicitly calls the Muse gap a provider-parity feature request and invites the Muse reader only. No explicit maintainer approval for this Copilot direction/scope is linked or present on this PR.

Get explicit maintainer approval for adding Copilot native session history and its cost/discovery scope, then link that approval. Existing Pi/Muse invitations do not approve every provider-parity feature.

thanks for trying to help improve t3 code. if you think this closure was a mistake, please open a fresh pr addressing the requirement above, and link back to this one.

@t3-code-bot t3-code-bot Bot closed this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant