Skip to content

fix(report): route displayed output through billableOutputTokens - #1116

Merged
iamtoruk merged 4 commits into
getagentseal:mainfrom
avs-io:fix/1115-billable-output-totals
Aug 23, 2026
Merged

fix(report): route displayed output through billableOutputTokens#1116
iamtoruk merged 4 commits into
getagentseal:mainfrom
avs-io:fix/1115-billable-output-totals

Conversation

@avs-io

@avs-io avs-io commented Aug 23, 2026

Copy link
Copy Markdown
Member

Problem

report, sessions, overview and optimize display output tokens that do not match the cost path after #1078.

Measured on Grok (184 sessions): report was short by exactly totalReasoningTokens (2,631,342). Cost was already correct.

Root cause

billableOutputTokens(provider, output, reasoning) is the source of truth: exclusive providers add reasoning; {claude, codex, copilot} already include it in output.

Cost / models / audit use the helper. Day aggregation, period data, sessions JSON, overview and optimize.ts context-bloat still read raw outputTokens or blindly sum output + reasoning.

Change

  • Per-call day buckets go through billableOutputTokens.
  • Session-level totals go through sessionBillableOutputTokens (sum per call; fallback uses inferred provider).
  • Daily cache v28 re-derives finalized days so report matches the live parse.

User impact

Grok (and other exclusive providers) report output goes up by reasoning. Optimize no longer inflates generated-token denominators for Codex/Copilot/Claude.

Preservation

Cost, models report and audit were already on the helper. No rate changes. No provider parser changes.

Testing

HERMES_HOME=/tmp/cb-cleanhome npx vitest run tests/billable-output-1115.test.ts tests/day-aggregator.test.ts tests/sessions-report.test.ts tests/daily-cache.test.ts — 51 passed.

Closes #1115

Thanks @saulcanina.

avs-io added 4 commits August 23, 2026 17:31
Cost already used the helper. Report, sessions, overview and optimize
did not, so exclusive providers dropped reasoning and optimize
double-counted it for claude/codex/copilot. Daily cache v28 re-derives.

Closes getagentseal#1115
Compare, export, report JSON, overview Top-model/By-tool/day, and
menubar localModelSavings still summed raw output. Session totals
stay defined on aggregate-only and stub calls. Upgrade verifier
expects daily-cache.v28.json.
Per-call billable output was written under raw call.model while
parser buckets use getShortModelName. Display aliases split into a
zero-output named row and a phantom raw-id row. Aggregate-only
sessions fall back to each existing bucket.
Parser sessions key modelBreakdown by getShortModelName. Leftover
raw-id buckets (overview fixtures, cached summaries) were minting a
second $0 / 0-call short-name row that findUnpricedModels flagged as
Unpriced and failed CI on getagentseal#1116.
@iamtoruk

Copy link
Copy Markdown
Member

Reviewed (DeepSeek draft + maintainer verification of every finding against the diff).

No verified defects. Claims checked: all display paths route through billableOutputTokens and the grok shortfall mechanism matches the measured 2,631,342 = totalReasoningTokens; cost path untouched; payload changes add-only. (The draft flagged a 'syntax error' at resolveModelBreakdownKey — that was a misquote of valid return derived ?? call.model; disregarded.)

Looks merge-ready from the review side; will run the standard parity pass before merge.

@iamtoruk
iamtoruk merged commit 561061c into getagentseal:main Aug 23, 2026
15 checks passed
avs-io added a commit to avs-io/codeburn that referenced this pull request Aug 23, 2026
…ntseal#1122 — daily cache v29

getagentseal#1115 took v28 on main. OrcaRouter pricing takes the next number.
Keep-both CHANGELOG. MIN_SUPPORTED stays 28.
avs-io added a commit to avs-io/codeburn that referenced this pull request Aug 23, 2026
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.

Reports drop Grok reasoning tokens; optimize double-counts them for codex/copilot after #1078

2 participants