mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-12 18:22:48 +03:00
A persisted per-(provider, model_id) override now wins over the static catalog / models.dev sync in getModelContextLimit, so a model whose real context window diverges from the catalog resolves correctly across combo routing, pre-flight compression, and family fallback. - migration 110_model_context_overrides + src/lib/db/modelContextOverrides.ts (CRUD, cacheless, defensive: null when the table is pre-migration; rejects non-positive windows). - read-path: getModelContextLimit returns override ?? catalog; getResolvedModelCapabilities stays override-free so the reconciler can compare against it. - src/lib/contextWindowResolver.ts: pure reconcileContextWindows (deps injected) + runContextWindowReconcile (reuses getAllSyncedAvailableModels — provider /models discovery, no new fetch) + periodic job. Writes auto:discovery overrides only when the discovered window diverges from the catalog; never touches manual overrides; self-heals. - registered in instrumentation-node.ts (CONTEXT_WINDOW_RECONCILE_INTERVAL, 0 disables). TDD: DB round-trip (7), read-path precedence (3), reconcile logic (6). Consumer suites green; typecheck:core + lint + cycles + migration-numbering + env-doc-sync clean.
18 lines
922 B
SQL
18 lines
922 B
SQL
-- 110_model_context_overrides.sql
|
|
-- Self-correcting context-window overrides per (provider, model_id). An override wins
|
|
-- over the static catalog / models.dev sync in getModelContextLimit(). Source 'manual'
|
|
-- is operator-set and is NEVER overwritten by the auto reconciler ('auto:discovery'),
|
|
-- which pins the window a provider's own /models discovery declares when it diverges
|
|
-- from the catalog. Read path: src/lib/modelCapabilities.ts::getModelContextLimit.
|
|
|
|
CREATE TABLE IF NOT EXISTS model_context_overrides (
|
|
provider TEXT NOT NULL,
|
|
model_id TEXT NOT NULL,
|
|
real_context INTEGER NOT NULL, -- the corrected context window (tokens), > 0
|
|
source TEXT NOT NULL DEFAULT 'manual', -- 'manual' | 'auto:discovery'
|
|
refreshed_at TEXT NOT NULL DEFAULT (datetime('now')),
|
|
PRIMARY KEY (provider, model_id)
|
|
) WITHOUT ROWID;
|
|
|
|
CREATE INDEX IF NOT EXISTS idx_mco_source ON model_context_overrides (source);
|