Skip to content

fix: cap cache percentage at 100% in status output (#26643)#26686

Open
Jimmy-xuzimo wants to merge 4 commits intoopenclaw:mainfrom
Jimmy-xuzimo:fix/cache-percentage-cap
Open

fix: cap cache percentage at 100% in status output (#26643)#26686
Jimmy-xuzimo wants to merge 4 commits intoopenclaw:mainfrom
Jimmy-xuzimo:fix/cache-percentage-cap

Conversation

@Jimmy-xuzimo
Copy link
Contributor

@Jimmy-xuzimo Jimmy-xuzimo commented Feb 25, 2026

Summary

Fixes issue #26643 - Cache hit rate can display values greater than 100% (e.g., 1142%) in the CLI status output.

Root Cause

The cache hit rate calculation divides cacheRead by total (tokens used). In some edge cases, cacheRead can exceed tokens used, resulting in percentages over 100%.

Fix

Cap the displayed percentage at 100% using Math.min(100, ...).

Changes

  • src/commands/status.format.ts: Added Math.min(100, ...) to cap cache percentage display

Before/After

Before:

28k/200k (14%) · 🗄️ 1142% cached

After:

28k/200k (14%) · 🗄️ 100% cached

Testing

  • Format check: ✅ Passed
  • Lint: ✅ Passed (0 warnings, 0 errors)
  • TypeScript: ✅ Passed

Impact

This is a display-only fix. The actual token counts are unaffected; only the percentage display is capped at 100% for display correctness.

Greptile Summary

Caps cache hit rate display at 100% to fix #26643 where cache reads could exceed tokens used and show percentages over 100% (e.g., 1142%). Also includes two additional fixes: adds google provider support for reasoning tag filtering (#26551), and adds Windows bash detection to skip bash-dependent tests when bash isn't available.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • All three fixes are straightforward and low-risk: the cache percentage cap is a display-only change using Math.min, the provider addition is a simple string match extension, and the test improvements add proper platform checks for Windows compatibility. Changes are well-tested and match the repository's coding standards.
  • No files require special attention

Last reviewed commit: faf0088

(5/5) You can turn off certain types of comments like style here!

- Add 'google' to the list of reasoning tag providers in provider-utils.ts
- This fixes issue openclaw#26551 where google provider (used by gemini-api-key auth) was not being recognized for reasoning tag filtering
- Add corresponding test case for google provider
- Fix issue openclaw#26643 where cache hit rate shows >100% (e.g., 1142%)
- Use Math.min(100, ...) to cap the percentage display
- This is a display-only fix for edge cases where cacheRead exceeds tokens used
@openclaw-barnacle openclaw-barnacle bot added commands Command implementations docker Docker and sandbox tooling size: S labels Feb 25, 2026
@openclaw-barnacle
Copy link

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle bot added the stale Marked as stale due to inactivity label Mar 3, 2026
@Jimmy-xuzimo Jimmy-xuzimo force-pushed the fix/cache-percentage-cap branch from faf0088 to 4ccf9a9 Compare March 3, 2026 05:43
- Rebasing on latest main branch
- PR is still valid and ready for review
- No functional changes in this update
@openclaw-barnacle openclaw-barnacle bot removed the stale Marked as stale due to inactivity label Mar 4, 2026
@Jimmy-xuzimo
Copy link
Contributor Author

Following up on this PR

This PR fixes cache hit rate display showing values over 100% (e.g., 1142%) in CLI status output.

Summary

  • Issue: [Bug]: status cached percentage >100% #26643
  • Root Cause: cacheRead can exceed tokens used in edge cases
  • Fix: Cap displayed percentage at 100% using Math.min(100, ...)
  • Testing: Format ✅, Lint ✅, TypeScript ✅
  • Greptile Review: 5/5 confidence ✅

This is a display-only fix with minimal risk. Could a maintainer please review?

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations docker Docker and sandbox tooling size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: status cached percentage >100%

1 participant