Skip to content

feat(agents): add copilot usage - #9945

Closed
legendik wants to merge 3 commits into
omacom:quattrofrom
legendik:feat/copilot-usage
Closed

legendik wants to merge 3 commits into
omacom:quattrofrom
legendik:feat/copilot-usage

Conversation

@legendik

@legendik legendik commented Sep 3, 2026

Copy link
Copy Markdown

Summary

Adds GitHub Copilot as a fourth agent in the agents panel, alongside Claude, Codex, and Fireworks. Ships the omarchy-agent-usage-copilot collector, panel icons, and test coverage — the plugin itself is untouched, since a new collector is all a new agent needs.

How it works

Local stats. The Copilot CLI's session store (~/.copilot/session-store.db) records every billed request in its assistant_usage_events table: day, model, session, token split, and cost in nano AI units. The collector snapshots the WAL-mode database via SQLite's online backup API (no copying of db + -wal siblings, no blocking the writer) and aggregates in Python. CLI versions whose store predates that table fall back to scanning session transcripts under ~/.copilot/session-state. Neither source needs the network. Honors COPILOT_HOME for non-default installs, like CLAUDE_CONFIG_DIR / CODEX_HOME in the other collectors.

Monthly allowance. The meter is an allowance of AI credits. When GitHub's internal quota endpoint (the one the editor plugins use) answers, the account-wide figure is authoritative — it counts every machine, IDE, and agent on the entitlement, and provides the plan label and reset date. The probe needs a token from COPILOT_QUOTA_TOKEN, GH_TOKEN, GITHUB_TOKEN, or gh auth token; every failure is soft and falls back to this machine's CLI spend against a plan allowance from ~/.config/omarchy/agents/copilot.json:

{ "plan": "pro", "monthlyCredits": 1500, "remote": true }

 plan  ( free / student / pro / pro+ / max / business / enterprise ) picks a default allowance;  monthlyCredits  overrides it;  remote  turns the quota probe off. A meter labeled "(est.)" is the local estimate; a plain "Monthly allowance" is the live account figure. A machine that never ran the CLI reports nothing and the panel stays hidden, per the plugin's contract.

Follows the sibling collectors' conventions: same  --force  /  --limits-only  freshness contract, versioned cache envelope, atomic cache writes, and auth guidance surfaced in  authHelpText .

image

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium risk] Adds a new agent collector for GitHub Copilot usage.

The PR appears safe to merge based on the changes since the previous review.

Summary

The PR adds a Copilot usage collector, panel icons, documentation, and tests. The collector reads a SQLite session store or transcript fallback and uses a remote account quota when available.

Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Store[Copilot session store] --> Collector[Usage collector]
  Transcripts[Session transcripts] -->|fallback| Collector
  Quota[GitHub quota] -->|when available| Collector
  Config[Local configuration] --> Collector
  Collector --> Panel[Agents panel]
Loading

Reviews (3) · Last reviewed commit: "fix(agents): book copilot transcript usa..."

Comment thread bin/omarchy-agent-usage-copilot Outdated
Comment thread bin/omarchy-agent-usage-copilot Outdated
Comment thread bin/omarchy-agent-usage-copilot Outdated
Comment thread test/shell.d/agent-usage-copilot-test.sh Outdated
Comment thread test/shell.d/agent-usage-copilot-test.sh Outdated
- Rewrite the transcript fallback for the real event format: count
  user-typed user.message prompts, and take tokens and cost from the
  cumulative session.shutdown modelMetrics as the increase since the
  previous shutdown. Replies after the last shutdown count on their
  output tokens alone.
- Remove the 20,000-row store cap. Rows stream through a shared running
  total, so lifetime totals cover the whole store.
- Stop counting tokens twice: store and shutdown input already includes
  cache reads and writes, and output already includes reasoning tokens.
- Read the live quota snapshot as AI credits, not nano units.
- Leave an unconfigured plan unknown instead of defaulting to Pro.
- Pin the test timezone and cover the transcript fallback, a store past
  the old cap, an unset plan, and a mocked live quota.
Comment thread bin/omarchy-agent-usage-copilot Outdated
Comment thread test/shell.d/agent-usage-copilot-test.sh
- Split each shutdown's usage over the days its replies landed on:
  output by each day's reply output, input, cache, and cost by reply
  count. A session that spans midnight or a month boundary no longer
  books everything on the shutdown's day.
- Wait out UTC midnight at the start of the test, so "today" and the
  allowance month cannot change mid-run, and cover a segment that
  spans midnight.
@dhh

dhh commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Thank you! Brought in with your authorship in #14040, reindented to two spaces, with the plan and allowance taken from GitHub's live answer and the last allowance kept through a failed check until it resets.

@dhh dhh closed this Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants