Skip to content

fix(copilot): report session credits missing from modelMetrics - #1824

Merged
ryoppippi merged 3 commits into
mainfrom
pullfrog/issue-1823-run-37156685621-attempt-1
Oct 9, 2026
Merged

ryoppippi merged 3 commits into
mainfrom
pullfrog/issue-1823-run-37156685621-attempt-1

Conversation

@github-actions

@github-actions github-actions Bot commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1823.

Copilot sessions whose modelMetrics breakdown does not cover every credit billed in the session-wide totalNanoAiu lost that usage. The Copilot adapter now compares the session total against the per-model totals across shutdowns and trailing session.usage_checkpoint events, and reports credits that stay unexplained at every later snapshot as cost-only unknown rows (0 tokens, $0.01 per credit). A breakdown that a later shutdown catches up on is not counted twice.

  • Per-model credits are collected from every shutdown, and --until only limits which rows are emitted, so a date-bounded report matches the unbounded one (ported from @erwindamsma's branch).
  • Unified reports keep zero-token rows that still carry a cost, so ccusage daily / monthly match ccusage copilot daily / monthly.
  • In calculate mode the unknown rows cost $0, following the usual precomputed-cost semantics.

Co-authored-by: Erwin Damsma [email protected]

@coderabbitai

coderabbitai Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 307aed11-df4a-4bc2-b9f4-fa23d74280d3

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
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Oct 3, 2026 •

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
ccusage-guide dbbdd79 Commit Preview URL

Branch Preview URL
Oct 09 2026, 10:30 PM

@erwindamsma

Copy link
Copy Markdown
Contributor

One more case I found while reviewing: per-model credits are only collected up to --until, so a breakdown that a later shutdown catches up on counts as an unknown gap whenever the catch-up falls after --until, and a day's cost then depends on the report range. Fix and test (credit_gaps_do_not_depend_on_until): erwindamsma@390d57a

erwindamsma and others added 2 commits October 9, 2026 23:27
Per-model credits were only collected up to `--until`, so a breakdown
that a later shutdown catches up on counted as a credit gap whenever the
catch-up fell after `--until`. A day's cost then depended on the report
range. Collect them from every shutdown and keep `--until` for which
rows are emitted, so a date-bounded report matches the unbounded one on
the days they share.
Copilot credit gaps are reported as zero-token rows with a cost, so
dropping every zero-token summary hid them from unified daily and
monthly reports while focused reports and session still showed them.
@pkg-pr-new

pkg-pr-new Bot commented Oct 9, 2026

Copy link
Copy Markdown

Open in StackBlitz

ccusage

npx https://pkg.pr.new/ccusage@1824

@ccusage/ccusage-darwin-arm64

npx https://pkg.pr.new/@ccusage/ccusage-darwin-arm64@1824

@ccusage/ccusage-darwin-x64

npx https://pkg.pr.new/@ccusage/ccusage-darwin-x64@1824

@ccusage/ccusage-linux-arm64

npx https://pkg.pr.new/@ccusage/ccusage-linux-arm64@1824

@ccusage/ccusage-linux-x64

npx https://pkg.pr.new/@ccusage/ccusage-linux-x64@1824

@ccusage/ccusage-win32-x64

npx https://pkg.pr.new/@ccusage/ccusage-win32-x64@1824

commit: dbbdd79

@ryoppippi
ryoppippi merged commit c788127 into main Oct 9, 2026
35 checks passed
@ryoppippi
ryoppippi deleted the pullfrog/issue-1823-run-37156685621-attempt-1 branch October 9, 2026 23:10
@github-actions github-actions Bot mentioned this pull request Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

ccusage performance comparison

PR SHA: dbbdd799e86f
Base SHA: fc439a277719

Performance comparison skipped.

Base package URL was not ready before 300.000s. Fixture performance comparison requires a base package when --base-dir is not provided.

Base package: fc439a277719

@github-actions

github-actions Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

ccusage performance comparison

PR SHA: dbbdd799e86f
Base SHA: fc439a277719

Performance comparison skipped.

Base package URL was not ready before 300.000s. Fixture performance comparison requires a base package when --base-dir is not provided.

Base package: fc439a277719

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.

Copilot: usage missing when modelMetrics doesn't cover the whole session

2 participants