Skip to content

fix(roi): repair $NaN / [object Object] in cco-roi cost table#31

Merged
egorfedorov merged 1 commit into
mainfrom
fix/roi-cost-nan
Jun 24, 2026
Merged

fix(roi): repair $NaN / [object Object] in cco-roi cost table#31
egorfedorov merged 1 commit into
mainfrom
fix/roi-cost-nan

Conversation

@egorfedorov

Copy link
Copy Markdown
Owner

Summary

/cco-roi is fully broken in its money output — same bug class as #29, just in src/roi.js instead of src/report.js.

Bug

roi.js treats MODEL_COSTS[model] as a scalar price per million tokens:

const cost = MODEL_COSTS[model];          // line 58
const costPerSession = (avgTokens / 1e6) * cost;
pricePerM: `$${cost}`,

But in utils.js the values are objects:

'opus': { input: 5, output: 25, contextWindow: 1_000_000 },

So tokens * { input, output, ... }NaN, and `$${cost}`$[object Object]. The entire "Monthly Savings by Model" table and the "Team ROI" figures were garbage.

Before:

Model     $/M tok            Per session   Per day    Per month   Per year
Haiku     $[object Object]   $NaN          $NaN       $NaN        $NaN
...
Team ROI: Monthly: $NaN

Fix

Use the MODEL_INPUT_COST accessor utils.js already exports for exactly this (input price per model), matching the #29 fix.

After:

Model     $/M tok   Per session   Per day    Per month   Per year
Haiku     $1        $0.01         $0.05      $1          $17
Sonnet    $3        $0.03         $0.14      $4          $52
Opus      $5        $0.05         $0.24      $7          $86
Team ROI: Monthly: $70   Yearly: $840

Verification

  • node --check src/roi.js → OK
  • node src/roi.js → real numbers, no NaN / [object Object]
  • npm test → 139/139 pass

🤖 Generated with Claude Code

roi.js treated MODEL_COSTS[model] as a scalar price, but in utils.js the
values are objects ({ input, output, contextWindow }). So every cost
calculation (savings per session/day/month/year, team ROI) resolved to
NaN, and the "$/M tok" column printed "$[object Object]".

Same bug class as #29 fixed in report.js — just missed in roi.js. Use the
MODEL_INPUT_COST accessor that utils.js already exports for this purpose.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@egorfedorov egorfedorov merged commit 12a3a3b into main Jun 24, 2026
5 checks passed
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.

1 participant