Repository navigation
Conversation
Yevanchen
left a comment
There was a problem hiding this comment.
Thanks for taking this on, @FradSer. The pricing problem in #691 is real. Against today's official pricing pages, main's hand-maintained table is wrong for Claude Sonnet 5, Opus 4.5–4.7, Haiku 4.5, and DeepSeek V4, and models.dev has all of them right. I'd like to land that part, but much smaller than this PR.
What #691 needs today. Prices in cost-pricing.ts are the only model metadata Mosoo maintains by hand. Presets don't store capabilities, limits, or lifecycle status, and a display name is one reviewed line per preset. The first step is therefore narrow: reference prices come from a checked-in models.dev subset instead of the hand-written table. Everything else can wait until something consumes it. I've narrowed #691's scope to match.
Requested changes
- Pricing only.
- Drop the display-name import, protocol resolution from
npm, the catalog metadata fields,canonical_model_id, and theopencode-goprovider (that belongs with #684). - Leave
pkgs/runtime-catalogunchanged so the web bundle doesn't carry the snapshot. Its minified bundle grows from 12.9 KB to 229 KB here.
- Drop the display-name import, protocol resolution from
- One snapshot, no history.
- Usage events already persist their computed cost and price snapshot, so a refresh doesn't reprice recorded usage. OpenCode works the same way: it computes cost once at step end from the current catalog and stores it (
packages/core/src/session/runner/step.ts). - Please remove the append-only history, Run-creation-time price selection (
pricingAtMs), and the dated schedules. Git history covers provenance and rollback.
- Usage events already persist their computed cost and price snapshot, so a refresh doesn't reprice recorded usage. OpenCode works the same way: it computes cost once at step end from the current catalog and stores it (
- A small refresh script.
- Fetch
api.json, keepinput,output,cache_read,cache_write, and contexttiersfor the mapped providers, and write the file. Review is the git diff. - A script a maintainer runs by hand doesn't need the lock file, atomic rename, bounded body reader, 575-line validator, or a weekly/monthly cadence. A prices-only subset is about 45 KB.
- Fetch
- Don't abstain when a rate is missing or extra.
- Bill reasoning tokens at the output rate and ignore audio rates, as OpenCode does (
packages/core/src/session/usage.ts). DeepSeek V4'sreasoningrate equals its output rate, and Gemini 3.5 Flash'sinput_audiorate equals its input rate. Output tokens already include reasoning tokens, and audio isn't metered. As written, DeepSeek V4 Pro/Flash and Gemini 3.5 Flash (bothgeminiandopencode) becomeunknown. - When
cache_readorcache_writeis omitted, bill those tokens at the input rate, as if they weren't cached. OpenCode treats an omitted cache rate as 0, butnormalizeUsageTokenscarves cache tokens out of input, so 0 would make them free. - As written,
missingCachePriceturns any call with cache-creation tokens intounknown. That affects 10 more presets that main prices today:gpt-5.5,gpt-5.4,gpt-5.4-mini,gpt-5.2,kimi-k2.6,kimi-k2.7-code,MiniMax-M3, and OpenCode'sdeepseek-v4-pro,glm-5.2, andminimax-m2.7.
- Bill reasoning tokens at the output rate and ignore audio rates, as OpenCode does (
- Keep one lookup path.
findImportedPricingreturnsnullon a miss, so the existing ID normalization never runs for current Runs.kimi/kimi-k2.6,zai/glm-4.6,minimax/minimax-m3,opencode/qwen3.6-plus, andkimi-k2.7-code-2026-06-25are priced on main butnullhere.- The existing guard tests ("has pricing for cost-managed preset models" and the normalization test) only pass because they were moved to an
atMsbefore the snapshot date. Please run them at the current time again. - Put a short list of reviewed overrides on top of the snapshot. For example,
gpt-5.3isunknownhere because models.dev doesn't list it. OpenCode layers its config over models.dev the same way.
- Split out the unrelated changes into their own PRs: prek
default_stages, ViteallowedHosts, the Gemini e2e harness, the Preview locators, and the ACP/PiadditionalDirectoriesbranch. Also drop the driver gitlink bump; it points at an unmerged fork commit (langgenius/mosoo-agent-driver#136).
Already right: using cost.tiers with the exact threshold (input + cache read + cache write, strict >) and ignoring the legacy context_over_200k matches both models.dev's guidance and OpenCode.
Capabilities and limits are worth importing once something consumes them. For example, limit and modalities could feed the typed model connection from #671, so Pi and custom OpenCode providers stop falling back to defaults. That deserves its own issue.
30b18fb to
969ed1a
Compare
|
@Yevanchen addressed all six requests in
Validation: API 1,215 pass / 1 optional native checkpoint skip / 0 fail; formatting, lint, all typechecks, GraphQL/OpenAPI checks and commit policy pass. An independent review found no confirmed issue. The local full gate is not green: the unchanged Driver ACP file has a 2,000 ms lifecycle timeout in Hosted follow-up: PR Check for |
Yevanchen
left a comment
There was a problem hiding this comment.
Thanks, @FradSer. This addresses all six requests.
What I checked on 969ed1a5:
- Running the refresh script's selection on today's
api.jsonreproducesmodels-dev.jsonbyte for byte. - Every cost-managed preset is priced at the current time, including calls with cache reads, cache writes, and long contexts. The OpenCode-style IDs (
kimi/kimi-k2.6and the others) resolve again. - PR Check passed.
Optional nit, fine as a follow-up: the gpt-5.3 override keeps main's 1.25× cache_write (2.1875). models.dev lists no cache_write for its same-priced siblings gpt-5.2 and gpt-5.3-codex, so they bill cache writes at the input rate. Dropping the field would match them.
Summary
pkgs/runtime-catalogand the web bundle remain unchanged.gpt-5.3preset. Missing cache rates use the applicable input rate; explicit zero rates remain free. Reasoning is already included in output tokens, and audio rates are ignored.>thresholds. Normalized input/cache buckets count once. Existing usage costs and price snapshots remain stored; there is no snapshot history, dated schedule, Run-time price selection, or historical repricing.just models-refreshscript, which fetchesapi.json, selects mapped-provider prices and context tiers, and writes the file for git-diff review.Why
Reference prices drifted from upstream while maintained by hand. This addresses the narrowed pricing-only scope of #691 and the six requests in #693 (review).
Closes #691.
Verification
Current head:
0e6420589f172880ee2115117f44e1666266ae09. The approved optional follow-up removes thegpt-5.3cache-write override, so the existing input-price fallback applies (1.75 USD/million tokens, previously 2.1875). Input, output and cache-read rates are unchanged. Current pricing-only diff: 10 files, +2,744/-631.Fresh verification on this exact head in an independent clean Linux checkout (Bun 1.4.0): pricing 53/53, persisted usage 6/6, idempotency 1/1 passed. No new pricing code change was needed during the subsequent maintenance check.
The hosted run for this head remains failed at the unchanged Driver backpressure fixture. Investigation reproduced the old fixture's premature burst-completion assertion: it could drain admitted work before all 900 notifications had arrived. The separate Driver #136 repair observes the final notification and peer write callback; it passed 40/40 repeated instances. This PR does not consume that branch or change its Driver gitlink. Rerunning the existing failed hosted job requires repository admin rights; no empty commit or branch change is used to retrigger it.
The results below are the earlier full verification on
969ed1a5; they are retained with their original source attribution.Source:
969ed1a54076a76bdf28f8fa845647e5f783371e, rebuilt on upstream83b7472121905c7657b26970da8f825371c6e768. Final diff: 10 pricing-related files, +2,741/-631 (2,126 added lines are JSON data).just test-package @mosoo/apipassed 1,215 tests, 1 optional native Claude/Host checkpoint skip, 0 failures. This includes all 52 pricing regressions and the usage/session identity integration tests.just checkgate is not green. The first Driver run had six failures. After completing the locked OpenCode dependency setup, its four contract tests passed; the OpenAI client file passed 55/55 on serial retest. The ACP backend file still passed 56/57:fails the turn before its terminal when a provider ignores a committed file reporttimes out after 2,000 ms waiting forharness.lifecycleFailure.83b74721checkout with the same upstream Driver pin49df36e9735f261829ea90b6570382bd33a67775, runtime and dependency versions reproduces the same ACP file result (56 pass / 1 fail). Selecting that test alone passes on both upstream and this revision. Driver is unchanged; this file-context-sensitive failure is not introduced by the pricing diff. New hosted checks remain separate from these local results.Impact
just models-refreshrecipe; no credentials, refresh cadence, deployment configuration, or new provider.Review
Design (UI changes only, otherwise N/A)
N/A — no UI changes.