openclaw - 💡(How to fix) Fix Feature: include cache tokens in /usage tokens footer [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#52684Fetched 2026-04-08 01:20:23
View on GitHub
Comments
0
Participants
1
Timeline
0
Reactions
0
Author
Participants
  • The data is already available in usage.cacheRead and usage.cacheWrite passed to formatResponseUsageLine
  • The formatting logic already exists in formatCacheLine (used by /status)
  • Minimal change: ~8 lines in formatResponseUsageLine

Root Cause

  • The data is already available in usage.cacheRead and usage.cacheWrite passed to formatResponseUsageLine
  • The formatting logic already exists in formatCacheLine (used by /status)
  • Minimal change: ~8 lines in formatResponseUsageLine

Fix Action

Workaround

I've patched formatResponseUsageLine locally to include cache info, works well.

Code Example

Usage: 1 in / 119 out · 🗄️ 94% hit · 29k cached, 348 new
RAW_BUFFERClick to expand / collapse

Problem

The /usage tokens per-response footer currently only shows Usage: Xk in / Yk out, but omits cache read/write token details.

Meanwhile, /status already shows a cache line (🗄️ Cache: 94% hit · 22k cached, 1.4k new), and the session JSONL logs contain full usage.cacheRead and usage.cacheWrite data — it's just not surfaced in the per-response footer.

Proposal

Include cache hit %, cache read tokens, and cache write tokens in the /usage tokens (and /usage full) footer. For example:

Usage: 1 in / 119 out · 🗄️ 94% hit · 29k cached, 348 new

This helps users understand per-message caching behavior without having to run /status or dig into session logs.

Context

  • The data is already available in usage.cacheRead and usage.cacheWrite passed to formatResponseUsageLine
  • The formatting logic already exists in formatCacheLine (used by /status)
  • Minimal change: ~8 lines in formatResponseUsageLine

Workaround

I've patched formatResponseUsageLine locally to include cache info, works well.

extent analysis

Fix Plan

To include cache hit percentage, cache read tokens, and cache write tokens in the /usage tokens footer, follow these steps:

  • Modify the formatResponseUsageLine function to include cache data.
  • Utilize the existing formatCacheLine function to format the cache information.

Example code changes:

// In formatResponseUsageLine function
const cacheLine = formatCacheLine(usage.cacheRead, usage.cacheWrite);
const usageLine = `Usage: ${usage.in} in / ${usage.out} out · ${cacheLine}`;

// Return the updated usageLine
return usageLine;

Verification

To verify the fix, check the /usage tokens response footer for the updated cache information. It should match the proposed format:

Usage: 1 in / 119 out · 🗄️ 94% hit · 29k cached, 348 new

Extra Tips

  • Ensure the usage.cacheRead and usage.cacheWrite data is accurately passed to the formatResponseUsageLine function.
  • Test the updated /usage tokens endpoint with various cache scenarios to confirm the fix works as expected.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix Feature: include cache tokens in /usage tokens footer [1 participants]