Skip to content

fix: round token counts up at the halfway thousand - #5592

Open
tonycoder-hub wants to merge 1 commit into
Aider-AI:mainfrom
tonycoder-hub:cursor/fix-format-tokens-rounding-41fb
Open

fix: round token counts up at the halfway thousand#5592
tonycoder-hub wants to merge 1 commit into
Aider-AI:mainfrom
tonycoder-hub:cursor/fix-format-tokens-rounding-41fb

Conversation

@tonycoder-hub

Copy link
Copy Markdown

format_tokens used round(count / 1000), and Python round() breaks ties to even, so 10500 rendered as 10k while 11500 rendered as 12k. Halves now round up.

Tests: python -m pytest tests/basic/test_utils.py tests/basic/test_coder.py -q — 53 passed, 29 subtests. Distinct from #5583-#5591.

round() breaks ties to even, so 10,500 tokens rendered as "10k" while
11,500 rendered as "12k". Round halves up so the k suffix is consistent.

Co-authored-by: Tony Coder <407243179@qq.com>
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants