fix(status): cap cache hit rate at 100% in status display#57400
fix(status): cap cache hit rate at 100% in status display#57400hydro13 merged 1 commit intoopenclaw:mainfrom
Conversation
formatTokensCompact() computed cache rate using totalTokens as the denominator. Legacy rows with undersized totalTokens produced impossible values like 120%. Use inputTokens + cacheRead + cacheWrite when prompt-side fields are available, falling back to max(totalTokens, cacheRead + cacheWrite) for legacy data. Fixes openclaw#26643
Greptile SummaryThis PR fixes a display bug in
Confidence Score: 5/5Safe to merge — the fix is narrowly scoped to a display-only calculation, is mathematically sound, and is covered by regression tests. No P0 or P1 findings. The denominator logic is correct (prompt-side tokens only), edge cases (zero inputTokens, legacy undefined, NaN/Infinity) are all guarded, division-by-zero is impossible inside the existing cacheRead > 0 guard, and two new regression tests validate both code paths. No files require special attention.
|
| Filename | Overview |
|---|---|
| src/commands/status.format.ts | Denominator for cache hit rate now uses prompt-side token fields (inputTokens + cacheRead + cacheWrite) when available, with a safe Math.max fallback for legacy rows — correctly prevents >100% display values. |
| src/commands/status.test.ts | Two new regression tests added: one covering the legacy undersized-totalTokens path (clamped to 100%), one covering the inputTokens-present path (67% vs old 40%). |
| CHANGELOG.md | Changelog entry added for the cache hit rate fix. |
Reviews (1): Last reviewed commit: "fix(status): cap cache hit rate at 100% ..." | Re-trigger Greptile
|
Merged via squash.
|
…7400) formatTokensCompact() computed cache rate using totalTokens as the denominator. Legacy rows with undersized totalTokens produced impossible values like 120%. Use inputTokens + cacheRead + cacheWrite when prompt-side fields are available, falling back to max(totalTokens, cacheRead + cacheWrite) for legacy data. Fixes openclaw#26643
|
🤖 We're reviewing this PR with Aisle We're running a security check on the changes in this PR now. This usually takes a few minutes. ⌛ Progress:
Latest run failed. Keeping previous successful results. Trace ID: Last updated on: 2026-03-30T09:47:27Z |
…7400) formatTokensCompact() computed cache rate using totalTokens as the denominator. Legacy rows with undersized totalTokens produced impossible values like 120%. Use inputTokens + cacheRead + cacheWrite when prompt-side fields are available, falling back to max(totalTokens, cacheRead + cacheWrite) for legacy data. Fixes openclaw#26643
…7400) formatTokensCompact() computed cache rate using totalTokens as the denominator. Legacy rows with undersized totalTokens produced impossible values like 120%. Use inputTokens + cacheRead + cacheWrite when prompt-side fields are available, falling back to max(totalTokens, cacheRead + cacheWrite) for legacy data. Fixes openclaw#26643
…7400) formatTokensCompact() computed cache rate using totalTokens as the denominator. Legacy rows with undersized totalTokens produced impossible values like 120%. Use inputTokens + cacheRead + cacheWrite when prompt-side fields are available, falling back to max(totalTokens, cacheRead + cacheWrite) for legacy data. Fixes openclaw#26643
Summary
formatTokensCompact()computed cache hit rate usingtotalTokensas the denominator. Legacy session rows with undersizedtotalTokensproduced impossible values like "120% cached".Fix
Use
inputTokens + cacheRead + cacheWritewhen prompt-side fields are available. Fall back tomax(totalTokens, cacheRead + cacheWrite)for legacy data so the denominator never drops below the known cached tokens.Testing
src/commands/statuspnpm tsgo) cleanFixes #26643