Skip to content

fix(vscode): make cache hit rate write-aware - #12738

Merged
marius-kilocode merged 1 commit into
mainfrom
mountainous-shroud
Jul 31, 2026
Merged

fix(vscode): make cache hit rate write-aware#12738
marius-kilocode merged 1 commit into
mainfrom
mountainous-shroud

Conversation

@marius-kilocode

Copy link
Copy Markdown
Collaborator

The VS Code session usage bar currently calculates cache hit rate as cache reads divided by input plus cache reads. Because cache writes are excluded, sessions with significant write volume can display nearly 100% despite paying for millions of written tokens.

This changes the rate to include cache writes in the denominator, matching the write-aware calculation used by the TUI:

cache read / (input + cache read + cache write)

The screenshots below use the exact same persisted session and token counts. The display changes from 100.0% to 49.7%, while In 6, Cache R 19,242, and W 19,442 remain unchanged.

Before

VS Code session usage before the write-aware cache rate fix

After

VS Code session usage after the write-aware cache rate fix

@kilo-code-bot

kilo-code-bot Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

The extracted cacheRate helper matches the CLI's formatRate in packages/opencode/src/kilocode/plugins/model-usage.ts:65 (read / (input + read + write)), the zero-total guard is preserved, and the test expectation (20 / 35 = 57.1%) is arithmetically correct. Change is confined to Kilo-owned paths and includes a user-facing changeset.

Files Reviewed (4 files)
  • .changeset/write-aware-cache-rate.md
  • packages/kilo-vscode/tests/unit/model-usage.test.ts
  • packages/kilo-vscode/webview-ui/src/components/chat/TaskUsage.tsx
  • packages/kilo-vscode/webview-ui/src/context/model-usage.ts

Reviewed by claude-opus-5 · Input: 20 · Output: 3.4K · Cached: 449.8K

Review guidance: REVIEW.md from base branch main

@marius-kilocode
marius-kilocode merged commit 38b7d57 into main Jul 31, 2026
24 checks passed
@marius-kilocode
marius-kilocode deleted the mountainous-shroud branch July 31, 2026 14:08
t7tran pushed a commit to t7tran/kilocode that referenced this pull request Aug 14, 2026
fix(vscode): make cache hit rate write-aware
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.

2 participants