Skip to content

fix: stop attributing all turns after warmup as cache warming savings#363

Merged
BYK merged 1 commit into
mainfrom
fix-bogus-warmup-savings
May 16, 2026
Merged

fix: stop attributing all turns after warmup as cache warming savings#363
BYK merged 1 commit into
mainfrom
fix-bogus-warmup-savings

Conversation

@BYK
Copy link
Copy Markdown
Owner

@BYK BYK commented May 16, 2026

Summary

Fixes wildly inflated "cache warming savings" numbers on the costs page. A single warmup ping could generate 30+ bogus hits and tens of dollars in phantom savings because lastWarmupAt was never cleared when the user returned.

Changes

  • Critical fix: Clear lastWarmupAt after consuming the warmup in pipeline.ts — makes warmup attribution one-shot (only the first turn after a warmup gets credit, not every subsequent turn within the TTL window)
  • Display fix: Add totalWarmups lifetime counter to WarmupState so the "Hits/Warmups" column shows meaningful ratios instead of nonsensical ones like "38/0" (caused by warmupCount resetting per-break while warmupHits accumulates)
  • Update WarmingSnapshot, LiveSessionRow, and all UI rendering to use totalWarmups for display

Root Cause

lastWarmupAt was set when a warmup ping fired (cache-warmer.ts) but never cleared when the user returned. The hit-detection in pipeline.ts checked sinceWarmup < ttlMs — since lastWarmupAt persisted, every turn within the TTL window (up to 1h) had its entire cacheReadTokens attributed as warmup savings.

@BYK BYK self-assigned this May 16, 2026
lastWarmupAt was never cleared when the user returned, causing every
subsequent turn within the TTL window to have its entire cacheReadTokens
attributed as warmup savings. A single warmup ping could generate 30+
bogus hits and tens of dollars in phantom savings.

Also fixes the Hits/Warmups display showing nonsensical ratios like
38/0 by adding a totalWarmups lifetime counter (warmupCount resets
per-break for the break-even cap).
@BYK BYK force-pushed the fix-bogus-warmup-savings branch from 222ce2a to 39cd0c5 Compare May 16, 2026 17:32
@BYK BYK merged commit bd355f3 into main May 16, 2026
7 checks passed
@BYK BYK deleted the fix-bogus-warmup-savings branch May 16, 2026 17:35
@craft-deployer craft-deployer Bot mentioned this pull request May 16, 2026
6 tasks
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