openclaw - ✅(Solved) Fix Usage footer: token counts missing 'k' suffix, showing raw thousands [1 pull requests, 2 comments, 2 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#58875Fetched 2026-04-08 02:31:40
View on GitHub
Comments
2
Participants
2
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
commented ×1cross-referenced ×1

The usage footer appended to messages (when /usage full is enabled) displays token counts like:

Usage: 7 in / 545 out · session agent:main:main

The 7 in actually means ~7,000 input tokens, but there's no k suffix, making it look like 7 tokens. This is confusing.

Root Cause

The usage footer appended to messages (when /usage full is enabled) displays token counts like:

Usage: 7 in / 545 out · session agent:main:main

The 7 in actually means ~7,000 input tokens, but there's no k suffix, making it look like 7 tokens. This is confusing.

Fix Action

Fixed

PR fix notes

PR #58917: Fix usage footer input token formatting with cached prompt tokens

Description (problem / solution / changelog)

Summary

  • display input usage using prompt token totals (input + cacheRead + cacheWrite) in the response footer
  • keep cost estimation based on raw usage fields
  • add a regression test for cached-token-heavy runs

Testing

  • pnpm vitest run src/auto-reply/reply/agent-runner.misc.runreplyagent.test.ts -t "runReplyAgent response usage footer"

Closes #58875

Changed files

  • extensions/matrix/src/matrix/client.test.ts (modified, +12/-4)
  • extensions/telegram/src/outbound-adapter.ts (modified, +32/-7)
  • src/auto-reply/reply/agent-runner-usage-line.ts (modified, +41/-2)
  • src/auto-reply/reply/agent-runner.misc.runreplyagent.test.ts (modified, +37/-0)
  • src/cron/isolated-agent.delivery-target-thread-session.test.ts (modified, +4/-4)
  • src/cron/isolated-agent/delivery-target.ts (modified, +14/-5)
  • src/daemon/schtasks.startup-fallback.test.ts (modified, +57/-53)
  • src/infra/provider-usage.fetch.shared.test.ts (modified, +38/-19)
  • src/infra/provider-usage.fetch.shared.ts (modified, +3/-1)

Code Example

Usage: 7 in / 545 out · session agent:main:main

---

Usage: 7k in / 545 out · session agent:main:main

---

Usage: 38k in / 2.1k out · session agent:main:main
RAW_BUFFERClick to expand / collapse

Description

The usage footer appended to messages (when /usage full is enabled) displays token counts like:

Usage: 7 in / 545 out · session agent:main:main

The 7 in actually means ~7,000 input tokens, but there's no k suffix, making it look like 7 tokens. This is confusing.

Expected behavior

Usage: 7k in / 545 out · session agent:main:main

Or for larger numbers:

Usage: 38k in / 2.1k out · session agent:main:main

Context

  • OpenClaw version: 2026.3.24
  • The footer is auto-generated by the gateway, not by the agent
  • Output tokens appear correct (not divided), so the inconsistency between in/out formatting adds to the confusion

Suggested fix

Add human-readable formatting with appropriate suffixes (k, M) to the usage footer token counts.

extent analysis

TL;DR

Update the usage footer generation to include human-readable formatting with 'k' and 'M' suffixes for token counts.

Guidance

  • Review the gateway's auto-generation logic for the usage footer to identify where token counts are formatted and displayed.
  • Modify the formatting to include 'k' for thousands and 'M' for millions, ensuring consistency between input and output token counts.
  • Test the updated footer with various token count values to verify correct formatting, such as displaying '7k' for 7,000 tokens and '2.1k' for 2,100 tokens.
  • Consider adding documentation or comments to explain the formatting logic for future maintenance and updates.

Example

def format_token_count(count):
    if count >= 1000000:
        return f"{count / 1000000:.1f}M"
    elif count >= 1000:
        return f"{count / 1000:.0f}k"
    else:
        return str(count)

Notes

The provided solution assumes that the gateway's logic for generating the usage footer is accessible and modifiable. If the gateway is a third-party service, it may be necessary to submit a feature request or bug report instead.

Recommendation

Apply workaround by updating the usage footer generation logic to include human-readable formatting, as this will directly address the reported issue and improve the clarity of the displayed token counts.

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…

FAQ

Expected behavior

Usage: 7k in / 545 out · session agent:main:main

Or for larger numbers:

Usage: 38k in / 2.1k out · session agent:main:main

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 - ✅(Solved) Fix Usage footer: token counts missing 'k' suffix, showing raw thousands [1 pull requests, 2 comments, 2 participants]