fix(limits): floor the token display, never round it up - #49
Merged
Merged
Conversation
UX non-blocking on #48, and it closes a pair that was left half-done: the member portal guards this with `Math.floor` and the PUBLIC site did not. `maximumFractionDigits: 0` truncates nothing — it ROUNDS. Measured before and after: value before after 1048576 1M 1M 1500000 2M 1M 1900000 2M 1M Harmless at today's window, which rounds down anyway. But this page is read by people who have not paid yet, so it must never advertise MORE than the backend allows — and that is exactly the reasoning already written into cloud-ui's formatContextWindow. The guard belonged on the more public surface too, and I only put it on the private one. `roundingMode: 'floor'`, one option, no change to any published number. The other figures are unaffected: 3,000M / 3.000M and 400M render as before. `npm run build` clean; vitest 727 passed across 50 files. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
UX follow-up, same sentence as devops#312 and enterprise-api#48. "exactly what the Novita primary serves" was the wrong frame: Novita's `context_size` covers input AND output together, so 1,048,576 is the provider's total budget, not a servable input window. A prompt at the very top leaves no room for the reply, nothing on our side filters for it (`_pre_call_checks` is off), and the caller gets the provider's error on a number this page publishes. Comment only, no published number changes. `npm run build` clean; vitest 727 passed across 50 files. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
QA blocker, and it is the rule I have been applying all chain turned back on me: a guard that cannot fail is not a guard. `formatTokens(1_048_576)` renders "1M" whether the formatter floors or rounds, so the 727 green tests said nothing about the fix — they pass identically if `roundingMode: 'floor'` is deleted. There was no test anywhere referencing `1_500_000`, `floor` or `roundingMode`. It matters more here than in the member portal, which QA also spotted: `roundingMode` is an Intl.NumberFormat option, and a runtime that does not support it IGNORES IT SILENTLY — no error, just rounding again. So the question is not "is the word still in the source" but "does this runtime actually floor", and only an assert answers that. Verified by removing the option: `expected '2M' to be '1M'`. Restored: green. The second test pins the figures that must NOT change (1,048,576 → 1M, 3,000M / 3.000M, 400M), so a future rounding change cannot quietly move them. Also closed a seam QA found, the third of this shape in the chain: inserting the caveat paragraph left "It renders as" dangling at the end of the new block. The heuristic worth keeping — when you insert a block, read the sentence immediately before and immediately after it. `npm run build` clean; vitest 729 passed across 50 files. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
UX non-blocking on #48, and it closes a pair that was left half-done: the member portal guards this with
Math.floor, and the public site did not.maximumFractionDigits: 0rounds, it does not truncateHarmless at today's window, which rounds down anyway. But this page is read by people who have not paid yet, so it must never advertise more than the backend allows — which is exactly the reasoning already written into cloud-ui's
formatContextWindow. I put the guard on the private surface and not on the public one.roundingMode: 'floor', one option, no published number changes. Other figures unaffected:3,000M/3.000Mand400Mrender as before.Tests
npm run buildclean; vitest 727 passed across 50 files.🤖 Generated with Claude Code