fix(provider): derive a price tier's threshold from its own minimum - #839
Open
ANIRUDDHA ADAK (aniruddhaadak80) wants to merge 1 commit into
Open
ANIRUDDHA ADAK (aniruddhaadak80) wants to merge 1 commit into
ANIRUDDHA ADAK (aniruddhaadak80) wants to merge 1 commit into
Conversation
ANIRUDDHA ADAK (aniruddhaadak80)
requested review from
Aayam Bansal (aayambansal) and
Ishaan Gangwani (ishaan1124)
as code owners
September 29, 2026 18:34
|
ANIRUDDHA ADAK (@aniruddhaadak80) is attempting to deploy a commit to the InkVell Team on Vercel. A member of the Team first needs to authorize it. |
ANIRUDDHA ADAK (aniruddhaadak80)
force-pushed
the
fix/pricing-tier-threshold
branch
2 times, most recently
from
September 30, 2026 09:44
6f4aaf7 to
56f1a09
Compare
The threshold came from the previous tier's max, which matches only when the catalog is contiguous; a gap charged the higher rate below the tier's declared start. Also treat an explicit min of 1 as the base tier, since token counts start at 1, instead of dropping the model from pricing.
ANIRUDDHA ADAK (aniruddhaadak80)
force-pushed
the
fix/pricing-tier-threshold
branch
from
September 30, 2026 10:18
56f1a09 to
17a59cf
Compare
This branch has not been deployed
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.
What
ManagedPricing.parsebuilds each tier's threshold from the previous tier's end:and finds the base tier by falsiness:
Why it matters
A tier's start came from the tier above ending. The
??prefers the predecessor'smax_input_tokens, which is the same number only when the catalog is contiguous. Where it is not, the threshold lands in the direction that costs the user money:Selection in
src/session/index.ts:827is.filter((tier) => promptTokens > tier.threshold), so a 150-token prompt satisfies150 > 100and is billed at the 201+ rate — 51 tokens before the tier is meant to apply. An overlap errs the other way.An explicit base tier of
min_input_tokens: 1made the model vanish.!tier.min_input_tokensis false for1, so no base tier is found and thecontinuedrops the entire row. Token counts start at 1, somin: 1means the same as omitting it:The same
firstlookup drivesfast_mode_detailspricing, so a fast-tier model can disappear the same way.Verification
New
test/provider/managed-pricing-tiers.test.ts. Three of four fail before:After:
Two of the four are guards against over-correcting: the contiguous case must be unchanged (it is, and the existing
managed-pricing.test.tssuite still passes — 15/15 on three consecutive runs), and the third test states the selection rule directly so the threshold cannot drift from the>comparison that consumes it.The change
The
indexparameter is no longer used.Touched files are Prettier-clean (verified on LF-normalized copies; this Windows checkout's
core.autocrlf=truemakes Prettier flag every file repo-wide).Fixes #838