fix: stop attributing all turns after warmup as cache warming savings#363
Merged
Conversation
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).
222ce2a to
39cd0c5
Compare
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
lastWarmupAtwas never cleared when the user returned.Changes
lastWarmupAtafter 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)totalWarmupslifetime counter toWarmupStateso the "Hits/Warmups" column shows meaningful ratios instead of nonsensical ones like "38/0" (caused bywarmupCountresetting per-break whilewarmupHitsaccumulates)WarmingSnapshot,LiveSessionRow, and all UI rendering to usetotalWarmupsfor displayRoot Cause
lastWarmupAtwas set when a warmup ping fired (cache-warmer.ts) but never cleared when the user returned. The hit-detection in pipeline.ts checkedsinceWarmup < ttlMs— sincelastWarmupAtpersisted, every turn within the TTL window (up to 1h) had its entirecacheReadTokensattributed as warmup savings.