You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(sync): validate model usage tokens and fix multi-day token distribution
Three failing tests in CI:
- test 25: validates cached data and rejects invalid structures
- test 26: counts interactions only once for multi-model files
- test 284: processCachedSessionFile skips invalid inputTokens
Changes:
1. Add validation for individual model usage token values in the
processCachedSessionFile inner loop. Negative or non-finite inputTokens
or outputTokens now emit a warning ('invalid inputTokens') and the
model entry is skipped rather than producing negative rollup values.
2. Replace the interaction-proportional token distribution (which
calculated tokens as displayTokens * interactionFraction * outputFraction)
with a per-model dayFraction approach:
- inputTokens = round(cachedUsage.inputTokens * dayFraction)
- outputTokens = round(cachedUsage.outputTokens * dayFraction)
dayFraction = model's interactions on this day / model's total interactions
For single-day sessions dayFraction = 1.0 so the exact cached values
are used. For multi-day sessions each day gets a proportional share.
This also removes the need for a separate displayTokens/totalCachedTokens
scale factor since for real API data both sources are identical.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
0 commit comments