Skip to content

fix(dashboard): stop re-pricing finished history from live counters - #142

Merged
flyworker merged 1 commit into
mainfrom
fix/stable-historical-pricing
Sep 13, 2026
Merged

flyworker merged 1 commit into
mainfrom
fix/stable-historical-pricing

Conversation

@flyworker

Copy link
Copy Markdown
Member

A finished day should not change value

The same 30-day window, read three times in one hour on the live node:

bucket tokens_in 04:5x 05:2x 05:4x
2026-08-30 12,604,819 $7.8299 $21.7450 $4.0694
2026-08-31 11,047,018 $7.8285 $20.0643 $3.9217
2026-09-01 9,755,769 $6.4416 $17.2275 $3.2899

Window totals: $32.58, $85.88, $16.83. The token counts are identical in all
three readings — the history did not change, only the multiplier.

Why

Buckets recorded before the per-model column existed carry token counts but no
split, so they can only be valued at an average rate. That average came from
blendedRate(metrics, rates), which reads metrics.ModelMetrics — the
in-memory counters, which reset on restart and hold only what has served since.
Nine days of history, 94% of this window, were priced by whichever models
happened to have traffic in the current process. Three restarts today, three
different valuations of the same past.

The blend now derives from the per-model splits stored in the window, making
it a function of persisted data. Still an estimate — the card says so — but a
reproducible one. The live mix stays as the fallback for a window carrying no
split at all.

The same bug wearing a different hat

Model colours were assigned from lifetime per-model earnings, also in-memory.
Straight after a restart that list held one model, so the other five folded
into "Other" even though the history had full figures for them:

Qwen/Qwen3.8-27B  $0.5610
Other             $0.5059
Unattributed      $15.76

Merging the stored history in, ranking each model on whichever total is larger:

Qwen/Qwen3.8-27B      $0.5610   4.39M in / 260.3k out
openai/gpt-5.5        $0.1016   583.0k in / 117.7k out
openai/gpt-5.4        $0.0857   223.1k in / 43.0k out
openai/gpt-5.6-terra  $0.0776   554.1k in / 85.9k out
Other                 $0.2410
Unattributed          $15.78

Test

TestHistoryPricingDoesNotDependOnLiveCounters prices one window against two
very different live mixes. Without the change: $6 vs $300.

Not addressed here

The large Unattributed figure is correct, not a defect — those nine days
predate the per-model column and genuinely cannot be attributed. Worth a
separate look at how the panel communicates that, since it dominates the window.

A completed day changed value whenever the process restarted. The same 30-day
window read $32.58, $85.88 and $16.83 within an hour today, and the day of
2026-08-30 — a fixed 12,604,819 tokens in every reading — was reported at
$7.83, $21.74 and $4.07. Only the multiplier moved.

Buckets recorded before the per-model column existed carry token counts but no
split, so they can only be valued at an average rate. That average came from
blendedRate(metrics, ...), which reads the in-memory model counters — counters
that reset on restart and reflect only what has served since. Nine days of
history, 94% of the window, were priced by whichever models happened to have
traffic in the current process.

The blend now comes from the per-model splits stored in the window itself, so
it is a function of persisted data and prices the same window the same way
twice running. It is still an estimate and the card still says so; it is now a
reproducible one. The live mix remains the fallback for a window that carries
no split at all.

Model colours had the same root cause: they were assigned from the lifetime
per-model earnings, also in-memory, so after a restart every model that had not
yet served folded into "Other" despite the history holding its figures. The
stored history is merged in, ranking each model on whichever total is larger.
On this node that took the 30-day breakdown from one named model to four.
@flyworker
flyworker merged commit 875a31c into main Sep 13, 2026
1 check passed
@flyworker
flyworker deleted the fix/stable-historical-pricing branch September 13, 2026 21:55
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