Repository navigation
Closed
Feature
Copy link
Labels
enhancementNew feature or request
Description
Problem
Model facts (context window, max tokens, capabilities, price) are read-only metadata today, with no user override channel:
- A custom model (e.g. a relay/transit-station model id) that is neither in the catalog nor returned by the provider's
/v1/modelsfetch getscontextWindow = undefined, and the runtime falls back to hardcoded defaults (defaultCompactReserveTokens→ 16_384, context-budget-policy.ts:394). The user has no way to tell the app "this model actually has a 200K window". - The only custom-model entry point is a plain model-id string in the connection form (
settings-provider-copy.ts:104— "填写你的中转站模型 ID…或自定义模型名"). - Pricing has the same shape: a 17-entry hand-maintained snapshot (see feat(scripts): sync the full models.dev fact set (pricing, description, knowledge, input limits) #2329) plus the override editor coming in the Pricing settings work — but no unified "model facts" override surface.
This is one class of problem: the app's model facts come from catalog sync + provider fetch, and users have no override channel.
Ecosystem findings (surveyed local sources of Pi, opencode, Hermes, Codex CLI, Gemini CLI, LobeChat, Kimi Code)
| Project | Config surface | context window override | price override | Merge semantics |
|---|---|---|---|---|
| Pi | ~/.pi/agent/models.json |
✅ per-model | ✅ cost field |
providers.<id>.models[] upsert (add/replace) + providers.<id>.modelOverrides.<modelId> field-level patch, one ordered pipeline (provider-composer.ts:425-434), overrides = "topmost user-config layer" |
| opencode | opencode.json providers |
✅ limit.context field-merged ({...base, ...config}) |
✅ cost (whole-replace) |
models.dev fills first (builtin snapshot → disk cache → network), user config overrides last (config/plugin/provider.ts:76-113) |
| Hermes | config.yaml |
✅ 9-level priority ladder; user override only at the top, uncovered fields probe down | ❌ (live /v1/models pricing, display-only) |
Facts (id list, context, capabilities, price) and user overrides strictly separated; override keys are provider × model |
| Codex CLI | ~/.codex/config.toml |
✅ model_context_window, clamped by min(max_context_window) |
❌ | Built-in providers are reserved ids — cannot be overridden, only new names (config_toml.rs:899-918); user catalog replaces bundled catalog |
| LobeChat | DB tables (ai_models with source: builtin/custom/remote) |
✅ per-model contextWindowTokens |
✅ full pricing (only project that supports it) | Builtin rows protected from remote writes; user values override field-by-field; source immutable once set |
| Kimi Code | ~/.kimi-code/config.toml |
✅ maxContextSize (default 131072) |
❌ | Remote refresh owns a whitelist of fields only; user overrides never touched (model-alias-merge.ts:25-60) |
| Gemini CLI | ~/.gemini/settings.json |
❌ (uses compression ratio instead) | ❌ | Alias inheritance chain + level-scoped overrides |
Consensus patterns across all surveyed harnesses:
- Built-in facts are read-only generated artifacts (models.dev / compile-time snapshot); users never rewrite the built-in table.
- User override is field-level; context window is the universally supported field (price only in LobeChat — Maka's pricing override work would make us the second).
- Priority: user > remote/dynamic > built-in, with the built-in snapshot as offline fallback.
- Override keys are provider × model, not bare model id (Hermes: same id differs by serving provider).
Proposed shape
A user override layer in the spirit of Pi's models.json / opencode's providers section, paired with the generated pricing table from #2329:
models.json (user-editable; or a Settings UI equivalent)
├── models[] → add or whole-replace a model (id, api, baseUrl, contextWindow, maxTokens, capabilities, cost…)
└── modelOverrides → { "<provider>:<model>": { contextWindow?, maxTokens?, … } } field-level patches
Design points (borrowed from the survey):
- Field-level merge (
{ ...base, ...override }), the opencodelimitpattern — never whole-entry replacement, so catalog updates keep flowing to untouched fields. - Single ordered merge pipeline with a documented "user is topmost" layer (Pi's provider-composer.ts:425-434 is the reference).
- provider × model keys.
- Schema validation with graceful fallback (Pi: bad models.json → error surfaced, built-ins still work).
- Built-in facts stay read-only: generated from models.dev (metadata today, pricing after feat(scripts): sync the full models.dev fact set (pricing, description, knowledge, input limits) #2329); user file never writes them.
- Pricing override keeps going through the existing override editor (feat(desktop): add isolated Pricing settings editor #2218 direction) — the models.json layer is for facts that have no UI yet (context window first).
Relationship to open work
- feat(scripts): sync the full models.dev fact set (pricing, description, knowledge, input limits) #2329 — sync builtin pricing from models.dev: supplies the read-only built-in facts side; this issue supplies the user override side. The two land together as the complete "model facts" story.
- Pricing override editor (feat(desktop): add isolated Pricing settings editor #2218) — the price dimension of this layer already has a UI; keep it, don't duplicate it in models.json.
Validation
- Context budget decisions (context-budget-policy.ts:410-424) resolve the overridden window instead of the 16K fallback for a custom model.
- Contract test: override merges field-by-field; catalog refresh does not clobber overridden fields; unknown ids in modelOverrides are ignored (Pi semantics) or flagged.
- Offline: built-in snapshot still works with no models.json present.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or request
Activity
Nyvo-io commentedon Aug 11, 2026
I would like to take this issue. I audited current
mainafter #2399 and propose keeping model-fact overrides on the existing Runtime Host ownership path: a versioned, schema-validated, root-scoped authority keyed byprovider:model, with field-leveluser override > provider inventory > generated metadataprecedence. Effective facts will feed the canonical model catalog and pre-dispatch Run composition so context/input budgets use the override, while generated facts remain read-only and the existing pricing authority/UI is not duplicated. Unknown entries will remain non-sendable until referenced by an existing connection or saved model choice.I will cover contract/store/projection behavior, malformed-document fallback with bounded diagnostics, provider refresh preserving untouched and overridden fields, restart persistence, and end-to-end context-budget resolution with focused Core, Storage, Runtime Host, and execution tests. I will keep unrelated provider creation and model-picker redesign out of this slice. Please assign me if this boundary matches the intended scope.
Astro-Han commentedon Aug 13, 2026
Assigned! @Nyvo-io