Skip to content

feat(providers): take model capability data from models.dev - #294

Merged
GoDiao merged 1 commit into
mainfrom
feat/models-dev-9422c8
Nov 20, 2026
Merged

GoDiao merged 1 commit into
mainfrom
feat/models-dev-9422c8

Conversation

@GoDiao

@GoDiao GoDiao commented Nov 20, 2026

Copy link
Copy Markdown
Owner

What changed

Model capability data (context window, output limit, thinking mode and effort levels, image and PDF input) now comes from models.dev instead of our hand-maintained table and per-provider discovery.

  • Bundled snapshot. src/server/config/modelsDev.json, generated from models.dev on 2026-11-20 (324 providers, 10,028 models, 1.89 MB, 117 KB gzipped). It stores only the fields we read, one model per line. scripts/update-models-dev.ts refreshes it, and scripts/release.ts now refreshes it as part of a release; the release step fails if the fetch fails.
  • Hourly refresh in the sidecar. src/server/services/modelsDev/modelsDevRefresh.ts loads whichever is newer, the on-disk cache or the snapshot, then fetches models.dev once an hour with the cached ETag (a 304 only bumps the timestamp). The app keeps working from the last copy offline. The refresh lives apart from modelsDevStore.ts so the CLI, which loads the rules resolver, does not pull in the network settings chain.
  • Lookup. For a model id we try the providers mapped from the base URL, then the vendor providers. Within a provider: exact candidate keys first, then the longest prefix that ends at a separator. A dot is not a separator for models.dev ids, so deepseek-v3.2 does not fall back to deepseek-v3; our own table and the site entries still cut at dots, because their prefixes name families (kimi-k2 covers kimi-k2.6).
  • Layer order. fallback → format → our model entries → models.dev (source modelsDev) → corrections (source model) → site → discovered → user override. The model table keeps only what models.dev lacks: structuredOutput, our write format and native search for Claude, and five models models.dev does not list.
  • Corrections. corrections in modelRules.json holds 8 Anthropic entries where models.dev lists thinking that cannot be turned off but Anthropic's docs say it can (Haiku/Sonnet 4.5, Opus 4.5 through Opus 5). Each entry needs a vendor doc URL and links the upstream fix, fix(anthropic): add the thinking toggle to Claude models that can turn thinking off anomalyco/models.dev#14144. Corrections match the models.dev id actually hit, so dated or suffixed ids that land on that model get the fix too.
  • OpenRouter with Anthropic format gets a site entry with anthropic_adaptive, per https://openrouter.ai/docs/use-cases/reasoning-tokens.
  • Removed the OpenRouter, DeepSeek and Qwen discovery sources (src/server/upstream/contextWindows/{openrouter,deepseek,qwen}.ts) and the reasoning fields they fed.
  • UI. The model settings show "models.dev" as the source label (en + zh).
  • Docs: docs/features/harness/model-rules.md, the provider preset tutorial (en + zh), PRIVACY.md (the app now requests models.dev periodically), THIRD_PARTY_NOTICES.md (models.dev is MIT), and a CHANGELOG entry.

Why

The hand-maintained table covered a few dozen models and went stale with each release, and the three discovery sources each parsed a different provider API for the same facts. models.dev publishes these values for about 10,000 models across 324 providers under MIT.

How it was tested

  • bun test (full, after rebasing on main): 3325 pass, 0 fail (233 files)
  • cd desktop && bun run lint: passes (tsc, electron tsc, oxlint)
  • cd desktop && bun run test -- --run: 3139 pass, 4 skipped, 0 fail (238 files)
  • New tests: catalog parsing and lookup (modelsDev-catalog.test.ts), the refresh with cache, ETag and 304 (modelsDev-refresh.test.ts), the bundled snapshot and the 8 corrections (modelRules-builtin.test.ts), layer order, prefix and dot behavior in modelRules-resolve.test.ts, the release step (scripts/release.test.ts, scripts/update-models-dev.test.ts), and the source label (ProviderFormModal.test.tsx). No test touches the network; model-specific tests swap in a test catalog and restore it after each test.
  • Tests for the prefix and dot rules were checked against deliberately broken implementations (treating dots as separators in the models.dev lookup, not treating them as separators in our table, passing the normalized id to models.dev); each break fails at least one new test.
  • Measured with bun 1.4.2 (three runs each): the first lookup parses and validates the snapshot in 35–68 ms and adds about 10.9 MB of heap; a resolve then takes about 16–19 µs on a hit and 32 µs on a full miss.
  • OpenRouter (tested by the maintainer on 2026-11-20): Claude Haiku 4.5 and Sonnet 4.5 through OpenRouter's Anthropic-format endpoint accept adaptive, disabled and budget thinking (all return 200) and turn thinking on and off as expected; the effort level showed no visible effect. Opus 4.5 through OpenRouter was not tested.

Not done

  • The "models.dev" source label has not been checked in the dev app in the light and dark themes.

Closes #291

@GoDiao
GoDiao merged commit 894d4f5 into main Nov 20, 2026
11 of 12 checks passed
@GoDiao
GoDiao deleted the feat/models-dev-9422c8 branch November 20, 2026 16:04
@GoDiao GoDiao mentioned this pull request Nov 21, 2026
5 of 12 tasks
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.

Take per-model capability data from models.dev

1 participant