Skip to content

fix: restore totalCost undefined guard - #181

Merged
dirac-run merged 1 commit into
dirac-run:masterfrom
alexdim:fix/fb15a-cost-regression
Aug 14, 2026
Merged

fix: restore totalCost undefined guard#181
dirac-run merged 1 commit into
dirac-run:masterfrom
alexdim:fix/fb15a-cost-regression

Conversation

@alexdim

@alexdim alexdim commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

fix

restore getTotalCost() undefined guard in TaskRequestLoop.

what

PR #170 split rewrote #175 guard:

ctx.taskState.totalCost += metricsManager.getTotalCost() ?? 0

this silently records unknown pricing as 0.

change back to:

const cost = metricsManager.getTotalCost()
if (cost !== undefined) ctx.taskState.totalCost += cost

StreamingMetricsManager returns undefined for unknown pricing, 0 only when model explicitly free, and actual number for provider cost or computed paid cost. only add when defined.

test

  • src/core/task/__tests__/StreamingMetricsManager.test.ts passes
  • src/core/task/__tests__/TaskState.test.ts passes
  • npx tsc --noEmit clean except pre-existing src/shared/storage/types.ts(14,2) error
  • npx biome check src/core/task/TaskRequestLoop.ts reports 2 pre-existing formatter/import-sort errors also on master

FB-15a split rewrote 175 undefined guard as ?? 0,
silently recording unknown pricing as 0.
restore reviewer-approved guard: only add when cost defined.
@dirac-run
dirac-run merged commit a2900f6 into dirac-run:master Aug 14, 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.

2 participants