Skip to content

chore(pricing): refresh the bundled snapshot; a refresh can no longer drop a model's pricing - #1483

Merged
iamtoruk merged 4 commits into
getagentseal:mainfrom
ozymandiashh:chore/pricing-snapshot-refresh
Sep 19, 2026
Merged

iamtoruk merged 4 commits into
getagentseal:mainfrom
ozymandiashh:chore/pricing-snapshot-refresh

Conversation

@ozymandiashh

Copy link
Copy Markdown
Collaborator

Split out of #1478 per review: the pure snapshot refresh lands on its own, because it moves money that has nothing to do with the tier mechanism and the mechanism is inert without fresh data anyway.

What's in the data

  • 5,938 primary entries: 1,210 added, 298 repriced vs the 0.9.24 bundle. Among the additions, upstream shipped the Grok Build family (grok-build-latest, grok-build-0.1 and routes) — which makes grok-4.6-build priceable, so the Grok parser's authoritative-model rule now prefers the real modelUsage id (pin updated with the reasoning in place).
  • Four entries are genuinely gone upstream (the two friendliai llama-3.1 rows, bare and prefixed). Seven more are newly excluded by the bundler's per-token-output filter (twelvelabs embedding and gpt-image-2 rows that publish no per-token output cost) — a filter rule change, not upstream deletions, called out as such in the changelog.
  • Fallback: 51 from the gap-fill plus 9 carried forward, 203 → 60.

Two bundler rules from the review, both fixing real damage this regen exposed

  1. Completeness wins over first-write for vendor-prefixed aliases. Upstream added nebius/MiniMaxAI/MiniMax-M3 with no cache-read rate, and pass 2 handed the stripped alias to it on first write — the publisher's entry carrying the published 6e-8 cache-read was silently replaced, buildCosts fell back to input × 0.1 (3e-8), and 1,574 calls repriced by −$2.99. Now a sparser alias cannot displace a richer entry for the same model.
  2. A refresh can no longer leave a model without pricing. Previously-priced fallback entries carry forward when neither the new primary nor the gap-fill covers their key under the exact or vendor-prefixed form the resolution pipeline actually queries. Nine models would otherwise have lost all pricing: qwen3.5-plus, mercury-2.5-preview, inkling-small:batch, nex-n2-mini, nex-n2-pro, gpt-latest, gemma-4-31b-it:batch, gpt-oss-20b:batch, grok-latest. Coverage deliberately excludes date-stripped matches: qwen/qwen3.5-plus-20260420 shares the bare name but does not answer the undated query at runtime.

Verification

  • npm run bundle-litellm twice over (idempotent carry), MiniMax-M3 cache-read verified back at 6e-8, all nine carried keys present.
  • Root tsc --noEmit clean; affected suites green (models, pricing-fallback-data, grok pipeline with the updated pin, codex, parser c4, budget).

Regenerated from live LiteLLM/models.dev/OpenRouter: 5,938 primary
entries (1,210 added, 11 removed, 298 repriced vs the 0.9.24 bundle)
and 51 fallback entries; 394 primary entries carry a tier slot. The
Grok Build family upstream is what makes grok-4.6-build priceable,
shifting the Grok parser's authoritative-model pick to the real
modelUsage id (pin updated with the reasoning in the test).
… drop a model's pricing

Regenerated from live LiteLLM/models.dev/OpenRouter: 5,938 primary
entries (1,210 added, 298 repriced vs the 0.9.24 bundle), fallback 51
from the gap-fill plus 9 carried forward. Upstream actually removed
four entries (friendliai llama-3.1 bare and prefixed); seven more are
excluded by the per-token-output filter, which is a rule change and is
called out as one.

Two bundler rules from review:

- vendor-prefixed aliases no longer displace a richer entry for the
  same model: completeness (published cache slots) wins over
  first-write, so the new nebius/MiniMaxAI/MiniMax-M3 without
  cache-read rates cannot replace the publisher's entry that carries
  them;
- previously-priced fallback entries carry forward when neither the
  new primary nor the gap-fill covers their key exactly or
  vendor-prefixed - the form the resolution pipeline queries. Nine
  models would otherwise have lost all pricing; a dated variant
  sharing the bare name does not count as coverage because it does
  not answer the undated query.

The Grok Build family upstream makes grok-4.6-build priceable, so the
Grok parser's authoritative-model pick prefers the real modelUsage id
(pin updated with the reasoning in place).

@iamtoruk iamtoruk left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The snapshot regeneration itself is faithful. The top models by spend match upstream exactly, and no model in real use is dropped. The dollar impact on the maintainer's own data is negligible. But two things must change before this can land, because they cost other users money or hide a regression.

  1. Guard 2 coverage is wrong and drops pricing for 96 models. The bundler's coverage check uses Object.keys(snapshot).some(k => k.endsWith('/' + key)), which treats a bare id like grok-latest as covered by a vendor-prefixed key such as ~x-ai/grok-latest. But the runtime resolver getModelCosts in src/models.ts never tries <vendor>/<id> for a bare id, so those fallback entries are dropped and the models return null (unpriced). This is not just grok-latest: 96 of the 145 removed fallback keys price on main and return null on this PR, including claude-opus-4.8, claude-fable-5.1, the claude/gpt/gemini/kimi "-latest" aliases, and the batch variants. Fix: drop the endsWith('/' + key) clause or check against what the runtime resolver actually reaches, then regenerate the fallback so those entries stay priced.

  2. The grok-parser-pipeline test edit masks a regression. That test now mocks grok-4.6-build to null, so the change it pins is grok-latest losing its price and falling back to grok-build rates, not "grok-4.6-build prices through the Grok Build family" as the new comment says. Revert that test edit. Once fix 1 is in, grok-latest keeps its own price and the test should not need changing.

  3. The completeness-wins guard is not rate-neutral, so please either make it so or own the reprices. Beyond preventing a dropped price, it changes 43 input/output rates and 34 cache rates by itself, on the same upstream data, just by choosing a different row. Some of these are large, for example grok-3 from 3/15 to 1.25/2.5, grok-4 the same, mistral-large-latest from 8/24 to 0.5/1.5, deepseek-v3 from 1.14/4.56 to 0.27/1.1. These may well be the correct rows, but the PR presents the guards as hardening, not repricing. Either restrict the guard to replace only when input and output are identical (pure completeness), or keep the reprices and list them in the PR body and changelog so they are a deliberate, reviewed change.

One more thing: the finalized daily cache is not re-derived by a refresh, and there is no cache version bump here. So installed users only see any of this on days the cache is re-derived. Online, the live price feed wins anyway, so the bundle is only a gap-fill for offline or unpriced cases.

This is close, and the regeneration is good work. It just needs the coverage clause fixed, the test reverted, and the guard reprices owned or removed.

…uard, regenerated bundle (getagentseal#1483)

- coveredByKey is exact-key only: the resolver never reaches vendor/<id> for
  a bare query, so the old endsWith clause dropped 96 priced fallback ids.
- Pass 2 stripped writes are strictly slot-filling: a richer upstream row may
  only fill missing cache slots when input/output rates are identical, never
  re-price a filled slot (was re-pricing 43 input/output + 34 cache rates).
- Carry now rescues dropped primary rows as well as fallback entries (twelve
  ids this cycle), so a refresh cannot leave a previously-priced model null.
- Regenerated: 5,942 primary + 212 fallback; 159 carried; zero coverage
  regression and zero guard-caused rate changes vs upstream/main, verified by
  resolving every id from either bundle through the real getModelCosts.
…ntseal#1483)

Upstream LiteLLM now publishes a distinct z-ai/glm-5.3 rate, so the
prefixed spelling no longer equals the glm-5p2 sibling. Assert against
the snapshot's own row (the gpt-5.6-codex pattern) so the test survives
later upstream reprices and the z-ai/ -> zai/ namespace rename.
@ozymandiashh

Copy link
Copy Markdown
Collaborator Author

All three addressed on e69f12b0; re-measured rather than quoted.

1 — coverage is exact-key-only, and the loss it already caused is repaired. The endsWith('/'+key) clause is gone, with a comment stating the real reason (the resolver never reaches a vendor/<id> key for a bare query). Fixing the clause alone wasn't enough: this PR's first regen had already run under the broken rule and dropped main's fallback from 203 to 60, so the carry inherited a lossy baseline. The carry now seeds from the main∪HEAD union of both data files and also rescues previous primary rows upstream itself dropped or renamed (this cycle: gpt-image-2-2026-04-21 + its azure form, the Bedrock marengo embeds, the friendliai llama-3.1 rows — 12 ids) into the fallback tier, primary still consulted first. Verified at the resolver level with the real getModelCosts over the 6,154-id union of both trees' bundles: your 96 reproduce exactly on the previous head, and zero ids that price on main price null on this one. Bundle is now 5,942 primary + 212 fallback.

2 — test reverted byte-identical to main and passes 6/6 unmodified; grok-latest keeps its own price, so the original assertion needs nothing.

3 — the guard is now strictly slot-fill (your option A). Pass 2 replaces a stripped key only when input and output are identical and every slot the existing entry already carries keeps its value — it fills null slots, never re-prices a filled one. grok-3 and grok-4 are back at 3/15, mistral-large-latest back at 8/24. Rate-neutrality verified two ways: on today's identical fetched JSON, main's pass-2 vs this one — 0 input/output changes, 0 cache changes, 62 null-slot fills; and end-to-end, every remaining rate diff vs main is attributable to source data (181 same-key upstream reprices, 313 new upstream rows), none to the guard or the carry.

Two things disclosed rather than smuggled:

  • One test amendment, its own commit (e69f12b0): upstream now ships z-ai/glm-5.3 with a distinct rate, so tests/models.test.ts's sibling-equality assertion is false for any honest refresh. It now asserts the snapshot's own row (the gpt-5.6-codex pattern), which also survives the z-ai/ → zai/ rename live upstream already shows. Full suite after it: 4,277 passed, 5 skipped, 0 failed.
  • A caveat on the 12 carried ids: they price under their bare and vendor-prefixed spellings but not under router-prefixed ones (omniroute:…, cp/…) — pre-existing fallback-tier behavior, identical for all 203 fallback-only ids on main.

On your cache note — agreed, and deliberate: this PR doesn't bump DAILY_CACHE_VERSION; the stacked #1478 does (33 → 34), so once both land, a re-derivation picks up the corrected bundle exactly when the tier rates arrive too.

@iamtoruk
iamtoruk merged commit 3bb72ad into getagentseal:main Sep 19, 2026
26 of 27 checks passed
ozymandiashh added a commit to ozymandiashh/codeburn that referenced this pull request Sep 28, 2026
…s hygienic in the refreshed snapshot

The requested regeneration surfaced two upstream moves beside the tier
work. LiteLLM dropped `claude-opus-4`; a refresh carries dropped ids
into the fallback tier, but the Cursor-style alias `claude-4-opus`
resolves against primary rows, so the bare id fell to the snowflake
gateway row and under-priced by 3x. Pinned at Anthropic's list price
in MANUAL_ENTRIES so it stays primary. LiteLLM also repriced
grok-4.6's base input 2e-6 -> 1.25e-6 (tier rates unchanged); the
below-threshold literal follows. Both changes reproduce identically
with main's unchanged bundler on the same live responses.

Today's drops also exposed a gap in the getagentseal#1483 carry-forward: primary
files legitimately hold @pin, date-suffixed and free-on-both rows, and
carrying those verbatim imports exactly what
tests/pricing-fallback-data.test.ts keeps out of the fallback file
(main's own next refresh fails those tests today). The carry now skips
@pin/date-suffixed keys (no query can arrive in those forms) and
free-on-both rows (an unpriced model falls to expected-free handling);
vendor-prefixed keys stay carriable since queries match them verbatim.
@ozymandiashh ozymandiashh added enhancement New feature or request area: cli The codeburn CLI and its core parsing/reporting engine labels Sep 28, 2026
iamtoruk added a commit that referenced this pull request Sep 28, 2026
… where billing evidence exists (#1478)

* fix(pricing): carry long-context tier rates through bundling and price them where billing evidence exists

LiteLLM publishes *_above_<n>k_tokens rates for 418 models - OpenAI's
gpt-5.4/5.5/5.6 family above 272k, Anthropic above 200k, and 128k/256k/
512k tiers elsewhere - but the bundler flattened every entry to the
fixed five-slot tuple and calculateCost had no threshold dimension, so
a request past its threshold priced at the base rate forever (#1076).

The tuple gains an optional sixth slot {threshold, input, output,
cacheWrite, cacheRead}, the threshold parsed from the key suffix
because LiteLLM ships no numeric field (272k means 272,000; #1075
verified assuming 128k fabricates +64% spend). Old bundles parse
unchanged; CACHE_SCHEMA_VERSION moves to 5 (4 is taken on main by the
implicit cache-write billing) so a stale on-disk live-pricing cache
cannot reintroduce the old behavior; the live-fetch parser picks the
same tier up; service-tier _priority/_flex variants and the 1-hour
cache-write combination are not context thresholds and stay out.

A tier applies when the request's prompt tokens (input + cached input,
the existing grok-4.6 definition) reach the threshold, each published
rate replacing its base and omitted slots keeping the base.
Application is gated on billing evidence via TIERED_PRICING_PROVIDERS:
codex today, where the maintainer's corpus measurement shows the
surcharge passing through; a real Copilot session on gpt-5.6-terra
with ~6M-token prompts billed at the BASE rate, so Copilot keeps base
pricing until such evidence exists - applying it there would fabricate
spend, the exact class #1075 warned about. The audit report recomputes
through the same tier swap so recomputedTotalUSD keeps tracking
attributedCostUSD.

* fix(pricing): read tier rates only from the chosen threshold; e2e codex tier test

Repair pass from review: both tierOf implementations now collect rates
per threshold and read only from the largest one, so a hypothetical
two-tier entry can never mix the smaller tier's rates under the bigger
threshold; the bundler validates tier values exactly like the live
parser (finite, non-negative). A codex end-to-end test drives a real
rollout past gpt-5.5's 272k prompt threshold and asserts the tiered
arithmetic explicitly (a typo'd provider string in codex.ts would
leave the call at base rates and fail it), alongside the no-provider
base-rate control that keeps the real Copilot billing pin intact.
Comment fixes: the priceOverride wording, the grok pin's actual
resolution branch, and the threading note on TIERED_PRICING_PROVIDERS
for whoever adds the next provider.

* fix(pricing): recompute the audit tier per call and re-derive warm daily caches

Both review blockers:

- audit-report no longer feeds a bucket's SUMMED tokens into the
  per-call 272k threshold (a \,979 phantom gap on the reviewer's
  corpus, any tiered codex model clearing the threshold on the sum
  alone). The recompute accumulates per call, through the same tier
  swap calculateCost applies, with each call's own prompt total; a new
  fixture mixes one 300k call with 200 small ones whose sum blows past
  the threshold and pins that only the big call tiers. Web search
  stays on the base rates - it never participates in a tier.
- DAILY_CACHE_VERSION 33 -> 34 with MIN_SUPPORTED_VERSION raised to
  match, the cfdaa68 convention: a 33 file written under tierless
  pricing is below the floor, is not adopted as the finalized base,
  and its days re-derive off the warm session cache (\ of codex
  spend on the reviewer's corpus lives only in the daily cache). The
  migration tests pin the new floor contract: no version-diff repairs
  merge into a below-floor file, and the v30 adoption test tracks
  CURRENT.

Nits from review: the kimi precision tightening is reverted to (8, 5),
and the tieredCostsFor comment is rewrapped.

Measured on this machine's corpus, tier-only (branch vs the refresh
branch, same data): +\.43 lifetime codex - this corpus runs far
more sessions past 272k than the reviewer's 8-of-51,801 (+\.012964);
both numbers are real, the corpora differ.

* fix(pricing): preserve base alias selection when bundling context tiers

* fix(pricing): address the 28 Sep review - floor stays at 28, tier bills the implicit cache-write rate

Restore main's two carry-forward tests: with MIN_SUPPORTED_VERSION kept
at 28 (per the review's correction, warm caches re-derive identically
under 41/28, so raising the floor is unnecessary) a v33 file sits in
the adopt-with-repairs window again and main's expectations hold; the
tier's warm-cache coverage stays in daily-cache-version-rederivation.

The tier-omits-slot test bills an implicit cache-write at the input
rate of the costs object in effect (#1544), so the tiered expectation
is 1_000 * cacheWriteCostPerToken('gpt-5.5', tieredCosts).

Note on the Codex estimate path: an estimated prompt can cross a
long-context threshold and tier itself; measured corpora hold no
estimated calls that cross.

* fix(pricing): pin claude-opus-4 primary and keep carried fallback rows hygienic in the refreshed snapshot

The requested regeneration surfaced two upstream moves beside the tier
work. LiteLLM dropped `claude-opus-4`; a refresh carries dropped ids
into the fallback tier, but the Cursor-style alias `claude-4-opus`
resolves against primary rows, so the bare id fell to the snowflake
gateway row and under-priced by 3x. Pinned at Anthropic's list price
in MANUAL_ENTRIES so it stays primary. LiteLLM also repriced
grok-4.6's base input 2e-6 -> 1.25e-6 (tier rates unchanged); the
below-threshold literal follows. Both changes reproduce identically
with main's unchanged bundler on the same live responses.

Today's drops also exposed a gap in the #1483 carry-forward: primary
files legitimately hold @pin, date-suffixed and free-on-both rows, and
carrying those verbatim imports exactly what
tests/pricing-fallback-data.test.ts keeps out of the fallback file
(main's own next refresh fails those tests today). The carry now skips
@pin/date-suffixed keys (no query can arrive in those forms) and
free-on-both rows (an unpriced model falls to expected-free handling);
vendor-prefixed keys stay carriable since queries match them verbatim.

---------

Co-authored-by: Resham Joshi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli The codeburn CLI and its core parsing/reporting engine enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants