fix: persist precomputed t/s so reloaded sessions match live rate - #47
Conversation
Live header showed 145t/s but reopening the same session showed 3292t/s. Root cause: tokens_per_sec was never persisted, and the reload fallback divided token_count (billed total incl. prompt + cache) by decode time instead of output tokens. - Add messages.tokens_per_sec (migration v4), round-trip through history DAO + session conversions - Backfill output_tokens from billed usage.output buckets for pre-existing rows; never derive from tokens_used total - Render + notification paths: t/s fallback uses output_tokens only; total-only legacy rows show duration without t/s
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Deploying crabcode with
|
| Latest commit: |
eb0a66f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f94becfb.crabcode.pages.dev |
| Branch Preview URL: | https://fix-tps-reload-parity.crabcode.pages.dev |
… decode) Keep our pause-adjusted per-sample rate for the live provisional, but compute the finalized/persisted rate like opencode #46108 (packages/core/src/session/tokens.ts): round(billed_output / ((completed - firstToken) / 1000)), 250ms floor, no (n-1) inter-token adjustment, tool-call steps included via accumulated billed usage. Provider output already counts reasoning tokens, so no separate bucket is needed. Reload fallback in message_tokens_per_sec and the notification path use the same formula, so live, reloaded, and notified rates agree.
PR Review #47 — fix/tps-reload-parity -> mainBranch: PR Comment Body (paste to GitHub)Fixes live (~145t/s) vs reload (~3292t/s) mismatch by persisting precomputed What Changed (5 files, +216/-39)
Regressions?No blocking regressions found. Expected behavior shifts (intentional, not bugs):
No dead-code issue: Migrations?Yes — v4. Safe:
Pre-Merge Checklist
Confidence Bumps4/5 → 5/5 if: full Checks Run (read-only)
|
Live header showed ~145t/s but reopening the same session showed ~3292t/s.
Root cause:
tokens_per_secwas computed live from generation samples but never persisted, and the reload fallback dividedtoken_count(billed total incl. prompt + cache) by decode time instead of output tokens.Changes:
messages.tokens_per_sec(migration v4), round-tripped through history DAO + session conversions (plus 2 regression tests).output_tokensfrom billedusage.outputbuckets for pre-existing rows; never derive fromtokens_usedtotal.chat.rs:6633) + notification (app.rs:1732) paths: t/s fallback uses output tokens only; total-only legacy rows show duration without t/s.Note:
test_edit_tool_renders_codex_style_diff_summaryfails in worktrees (hardcodes main checkout path) — pre-existing, unrelated.