Skip to content

Copilot cost was never zero — we just were not reading it - #282

Merged
node9ai merged 1 commit into
mainfrom
dev
Sep 2, 2026
Merged

Copilot cost was never zero — we just were not reading it#282
node9ai merged 1 commit into
mainfrom
dev

Conversation

@node9ai

@node9ai node9ai commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

scanCopilotHistory hardcoded totalCostUSD: 0 behind the comment "event logs carry no token/cost rollup". The comment is wrong.

session.shutdown carries a modelMetrics rollup with inputTokens, outputTokens, cacheReadTokens and cacheWriteTokens — and costSync has been pricing it the whole time. The upload path reported $0.0426 of gpt-5-mini to the cloud while node9 scan displayed $0.00 for the same sessions.

A $0 beside a real agent does not read as "no data". It reads as free, which is the opposite of the truth and exactly the conclusion a user would act on.

No new arithmetic

parseCopilotSession already exists, is tested, and is what the upload path uses. scan simply never called it. Same shape as codexSessionCost: one function, several callers.

Writing a second Copilot cost function would have recreated the exact divergence fixed one commit ago for Codex — same pattern, different agent.

The vendor's own cost field is not consumption

Copilot reports requests.cost: 0 in real transcripts, because GitHub bills a subscription rather than tokens. The existing parser prefers it only when > 0 and otherwise prices the tokens. A test now pins that: trusting a billing field as a consumption figure is the same confusion the API value relabel exists to prevent.

Measured — both binaries built and run back to back, --all

copilot   $0.0000 -> $2.3526    <- the change
gemini    unchanged
codex     unchanged
claude    +$0.41                <- this session generating activity

Only Copilot moved.

Verification

4,295 tests, typecheck, lint, format clean. Mutation-tested three ways — restoring the hardcoded zero, removing the window filter, and trusting Copilot's cost field all turn the new tests red.

Corrected while measuring

Gemini reports $11.43 over --all, so it computes correctly and its 30-day $0 is an empty window, not a defect. I had grouped it with the suspects; that was wrong.

Antigravity remains a genuine $0 with no token data anywhere on disk. That one is a display problem — $0 should read — and it is the next commit, not this one.

🤖 Generated with Claude Code

`scanCopilotHistory` hardcoded `totalCostUSD: 0` behind the comment
"event logs carry no token/cost rollup". The comment is wrong.
session.shutdown carries a modelMetrics rollup with inputTokens,
outputTokens, cacheReadTokens and cacheWriteTokens, and costSync has been
pricing it the whole time — $0.0426 of gpt-5-mini reaching the cloud
while `node9 scan` displayed $0.00 for the same sessions.

A $0 beside a real agent does not read as "no data". It reads as free,
which is the opposite of the truth and exactly the conclusion a user
would act on.

No new arithmetic. parseCopilotSession already exists, is tested, and is
what the upload path uses; scan simply never called it. Same shape as
codexSessionCost: one function, several callers. Writing a second Copilot
cost function would have recreated the divergence fixed one commit ago
for Codex.

Copilot's own `requests.cost` is 0 in real transcripts because GitHub
bills a subscription, not tokens. The existing parser already prefers it
only when > 0 and otherwise prices the tokens; a test now pins that,
because trusting a vendor's billing field as a consumption figure is the
same confusion the "API value" relabel exists to prevent.

Windowed per row date. The rows carry their own `date`, so unlike Codex
no session-level guard is needed.

Measured, both binaries built and run back to back over --all:

  copilot   $0.0000 -> $2.3526    <- the change
  gemini    unchanged
  codex     unchanged
  claude    +$0.41                <- this session generating activity

Mutation-tested three ways: restoring the hardcoded zero, removing the
window filter, and trusting Copilot's cost field all turn the new tests
red.

Noticed while measuring: Gemini reports $11.43 over --all, so it computes
correctly and its 30-day $0 is simply an empty window — not the same
class of defect. Antigravity remains a genuine $0 with no token data
anywhere; that one is a display problem, and it is next.
@node9ai
node9ai merged commit 51803c7 into main Sep 2, 2026
12 checks passed
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

🛡️ node9 agent-security · ✅

No agent-security findings — no injectable workflows, unsafe agent configs, or unpinned MCP servers.

@node9ai

node9ai commented Sep 2, 2026

Copy link
Copy Markdown
Contributor Author

🎉 This PR is included in version 2.7.4 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant