Skip to content

Commit 0dcd6ab

Browse files
fix: status bar shows 26K instead of 260K for token counts with trailing zeros (NousResearch#3024)
format_token_count_compact() used unconditional rstrip("0") to clean up decimal trailing zeros (e.g. "1.50" → "1.5"), but this also stripped meaningful trailing zeros from whole numbers ("260" → "26", "100" → "1"). Guard the strip behind a decimal-point check. Co-authored-by: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com>
1 parent b646190 commit 0dcd6ab

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

agent/usage_pricing.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,8 @@ def format_token_count_compact(value: int) -> str:
649649
text = f"{scaled:.1f}"
650650
else:
651651
text = f"{scaled:.0f}"
652-
text = text.rstrip("0").rstrip(".")
652+
if "." in text:
653+
text = text.rstrip("0").rstrip(".")
653654
return f"{sign}{text}{suffix}"
654655

655656
return f"{value:,}"

0 commit comments

Comments
 (0)