fix(code-review): split cached token usage#4086
Conversation
| if (review?.model) { | ||
| return { | ||
| model: review.model, | ||
| tokensIn: review.total_tokens_in ?? null, |
There was a problem hiding this comment.
WARNING: "Input" token count has inconsistent semantics between the two return paths of getReviewUsageData.
The billing path (line 609) returns tokensIn: billing.totalUncachedTokens (cache-exclusive), so the footer/details render Input 200 · Cached 800. This fallback returns tokensIn: review.total_tokens_in, which is cache-inclusive: for v2 reviews it is back-filled from billing.totalTokensIn (the raw input_tokens sum, line 600), and for v1 reviews it is the SSE-accumulated prompt_tokens (cache-inclusive per OpenRouter convention, see processUsage.ts:755).
Consequently two reviews with identical actual usage render very differently depending on whether billing rows are still available: a new review shows Input 200 · Cached 800 while an older one shows Input 1000 · Cached —. Since the stated goal of this PR is to stop cached work from looking like new work, the fallback silently re-introduces that confusion for old reviews. Consider normalizing the fallback (e.g. only show total_tokens_in as a combined input when no cached breakdown exists, or relabel it Input (incl. cached)), so the "Input" label means the same thing across reviews.
Reply with @kilocode-bot fix it to have Kilo Code address this issue.
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Executive SummaryThe incremental commit correctly bounds the review-usage lookup window and fixes model consistency, but the previously-flagged inconsistent "Input" token-count semantics between the billing and fallback paths remains unresolved. Overview
Issue Details (click to expand)WARNING
Incremental Review NotesNew commit Verified correct:
Not addressed (carried forward): the WARNING above on line 623. This commit only changed the model field and added the upper bound; the fallback path still returns Files Reviewed (5 files in incremental diff)
Fix these issues in Kilo Cloud Previous Review Summary (commit fed3ff7)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit fed3ff7)Status: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Files Reviewed (8 files)
Notes
Reviewed by glm-5.2-20260616 · 865,208 tokens Review guidance: REVIEW.md from base branch |
Summary
Code reviews showed one large input number, which made cached work look like new work. This change separates input, output, and cached tokens in review comments and the review details page, while keeping old reviews readable when cache data is not available.
Verification
Visual Changes
N/A
Reviewer Notes
Billing data is loaded only for finished reviews, so active review polling does not add billing queries. Stored input totals and retry limits keep their existing meaning, and no database change is needed.