7.4 billion tokens per month. 34 free LLM providers. 635 free model endpoints. All behind one /v1 endpoint, plus any custom OpenAI-compatible endpoint. Smart routing, automatic failover, encrypted keys. Personal experimentation only.
TypeScript
fix(providers): remove the retired GitHub Models provider (#1557) (#1560)
Tashfeencece2df2af96
diff --git a/client/src/components/keys/shared.tsx b/client/src/components/keys/shared.tsxindex 001fcac8..a5e731a4 100644--- a/client/src/components/keys/shared.tsx+++ b/client/src/components/keys/shared.tsx@@ -60,7 +60,6 @@ export const PLATFORMS: { value: Platform; label: string; url: string; keyless?:{ value: 'nvidia', label: 'NVIDIA NIM', url: 'https://build.nvidia.com/settings/api-keys' },{ value: 'mistral', label: 'Mistral', url: 'https://console.mistral.ai/api-keys/' },{ value: 'openrouter', label: 'OpenRouter', url: 'https://openrouter.ai/keys' },- { value: 'github', label: 'GitHub Models', url: 'https://github.com/settings/tokens' },{ value: 'cohere', label: 'Cohere', url: 'https://dashboard.cohere.com/api-keys' },{ value: 'cloudflare', label: 'Cloudflare Workers AI', url: 'https://dash.cloudflare.com' },{ value: 'zhipu', label: 'Zhipu AI (Z.ai)', url: 'https://z.ai/manage-apikey/apikey-list' },diff --git a/docs/en/api/01-rest-api.md b/docs/en/api/01-rest-api.mdindex 5a89946d..828553f3 100644--- a/docs/en/api/01-rest-api.md+++ b/docs/en/api/01-rest-api.md@@ -162,7 +162,7 @@ final = client.chat.completions.create(print(final.choices[0].message.content)```-Works with `stream=True` as well — you'll get `delta.tool_calls` chunks followed by a `finish_reason: "tool_calls"` close. Under the hood, OpenAI-compatible providers (Groq, Cerebras, Mistral, OpenRouter, GitHub Models, HuggingFace, Cloudflare, Cohere compat) get the request passed through; Gemini requests get translated into Google's `functionDeclarations` / `functionResponse` shape and the response is translated back.+Works with `stream=True` as well — you'll get `delta.tool_calls` chunks followed by a `finish_reason: "tool_calls"` close. Under the hood, OpenAI-compatible providers (Groq, Cerebras, Mistral, OpenRouter, HuggingFace, Cloudflare, Cohere compat) get the request passed through; Gemini requests get translated into Google's `functionDeclarations` / `functionResponse` shape and the response is translated back.## Gemini Google Search grounding@@ -334,8 +334,6 @@ curl http://localhost:3001/v1/embeddings \| Family (`model`) | Dims | Providers (failover order) || --- | --- | --- || `gemini-embedding-001` *(default)* | 3072 | Google |-| `text-embedding-3-large` | 3072 | GitHub Models |-| `text-embedding-3-small` | 1536 | GitHub Models || `embed-v4.0` | 1536 | Cohere || `bge-m3` | 1024 | Cloudflare → Hugging Face || `qwen3-embedding-0.6b` | 1024 | Cloudflare |diff --git a/docs/en/architecture/00-high-level-index.md b/docs/en/architecture/00-high-level-index.mdindex f18c4613..9bf3e6c4 100644--- a/docs/en/architecture/00-high-level-index.md+++ b/docs/en/architecture/00-high-level-index.md@@ -85,7 +85,6 @@ A self-hosted, single-user, personal-use setup was re-reviewed against each prov| OpenRouter | ✅ Likely OK | April 2026 ToS sharpens the no-resale / no-competing-service clause; private single-user proxy still fine. || Cloudflare Workers AI | ⚠️ Ambiguous | No anti-proxy clause; covered by general Self-Serve Subscription Agreement. || NVIDIA NIM | ⚠️ Caution | Trial ToS §1.2 / §1.4: *"evaluation only, not production."* Free access is a recurring 40 RPM rate limit (the 2025 credit system was discontinued), but the evaluation-only scope stands. |-| GitHub Models | ⚠️ Caution | Free tier explicitly scoped to *"experimentation"* and *"prototyping."* || Cohere | ❌ Avoid | Terms §14 still forbids *"personal, family or household purposes."* || Zhipu (open.bigmodel.cn) | ✅ Likely OK | Personal/non-commercial research carve-out still in the platform docs. || Z.ai (api.z.ai) | ⚠️ Caution | New row — Singapore entity (distinct from Zhipu CN). §III.3(l) anti-traffic-redirect clause could plausibly be read against a proxy; no explicit personal-use carve-out. |diff --git a/docs/en/architecture/03-streaming-pipeline.md b/docs/en/architecture/03-streaming-pipeline.mdindex c9ece226..140323cd 100644--- a/docs/en/architecture/03-streaming-pipeline.md+++ b/docs/en/architecture/03-streaming-pipeline.md@@ -231,7 +231,6 @@ Thin adapter over shared fallback loop:| `rememberReasoning(sessionKey, modelKey, reasoning)` | Store per-session trace || `rescueInlineToolCalls(text, tools)` | Convert inline dialect → structured `tool_calls` || `repairToolArguments(args, schemas)` | Fix double-encoded JSON against request schemas |-| `truncateMessagesForGithub(messages)` | Trim history to GitHub Models input ceiling || `normalizeOutboundContent(chunk)` | Provider-specific response normalization || `sanitizeResponse(chunk)` | Redact secrets from streamed frames |diff --git a/docs/en/providers/01-supported-platforms.md b/docs/en/providers/01-supported-platforms.mdindex 2df8c030..7d3de037 100644--- a/docs/en/providers/01-supported-platforms.md+++ b/docs/en/providers/01-supported-platforms.md@@ -27,7 +27,6 @@ Of the 43 built-in platforms, **10 use dedicated adapters** and **33 ride `OpenA| `mistral` | Mistral | Keyed | OpenAI-compat | `api.mistral.ai/v1`. || `sambanova` | SambaNova | Retired (V23) | Not registered | Free tier permanently gone; kept in the type union for historical key rows. || `openrouter` | OpenRouter | Keyed | OpenAI-compat | Sends `HTTP-Referer`/`X-Title` headers; `:free` model suffix marks zero-cost routes. |-| `github` | GitHub Models | Keyed | OpenAI-compat | Routes to `models.github.ai/inference`; catalog uses `<publisher>/<model>` ids. || `cohere` | Cohere | Keyed | Native (`CohereProvider`) | Uses Cohere's OpenAI-compatible endpoint. || `cloudflare` | Cloudflare Workers AI | Keyed (`account_id:token`) | Native (`CloudflareProvider`) | Compound credential format parsed by the adapter. || `zhipu` | Zhipu (Z.ai / bigmodel.cn) | Keyed | Native (`ZhipuProvider`) | Console autodetect: a rejected domestic key is re-probed against the global `api.z.ai` host; 60s timeout covers glm-4.7-flash hidden reasoning. |diff --git a/docs/zh-cn/api/01-rest-api.md b/docs/zh-cn/api/01-rest-api.mdindex 69630f30..a038edeb 100644--- a/docs/zh-cn/api/01-rest-api.md+++ b/docs/zh-cn/api/01-rest-api.md@@ -141,7 +141,7 @@ final = client.chat.completions.create(print(final.choices[0].message.content)```-配合 `stream=True` 也可以,你会先收到一串 `delta.tool_calls` 分块,然后是一个 `finish_reason: "tool_calls"` 收尾。底层实现上,兼容 OpenAI 的提供方(Groq、Cerebras、Mistral、OpenRouter、GitHub Models、HuggingFace、Cloudflare、Cohere 兼容模式)会直接透传请求;发往 Gemini 的请求会被翻译成 Google 的 `functionDeclarations` / `functionResponse` 结构,响应再翻译回来。+配合 `stream=True` 也可以,你会先收到一串 `delta.tool_calls` 分块,然后是一个 `finish_reason: "tool_calls"` 收尾。底层实现上,兼容 OpenAI 的提供方(Groq、Cerebras、Mistral、OpenRouter、HuggingFace、Cloudflare、Cohere 兼容模式)会直接透传请求;发往 Gemini 的请求会被翻译成 Google 的 `functionDeclarations` / `functionResponse` 结构,响应再翻译回来。## Gemini 的 Google 搜索接地@@ -251,8 +251,6 @@ curl http://localhost:3001/v1/embeddings \| 系列(`model`) | 维度 | 提供方(故障转移顺序) || --- | --- | --- || `gemini-embedding-001` *(默认)* | 3072 | Google |-| `text-embedding-3-large` | 3072 | GitHub Models |-| `text-embedding-3-small` | 1536 | GitHub Models || `embed-v4.0` | 1536 | Cohere || `bge-m3` | 1024 | Cloudflare → Hugging Face || `qwen3-embedding-0.6b` | 1024 | Cloudflare |diff --git a/docs/zh-cn/architecture/00-high-level-index.md b/docs/zh-cn/architecture/00-high-level-index.mdindex 9d90cfef..5f2329d0 100644--- a/docs/zh-cn/architecture/00-high-level-index.md+++ b/docs/zh-cn/architecture/00-high-level-index.md@@ -85,7 +85,6 @@ FreeLLMAPI 是一个自托管的、兼容 OpenAI 的网关,把约 34 家提供| OpenRouter | ✅ 大概率可以 | 2026 年 4 月的条款强化了禁止转售、禁止竞争性服务的条款;私有单用户代理仍然没问题。 || Cloudflare Workers AI | ⚠️ 模糊 | 没有反代理条款;受通用的自助订阅协议约束。 || NVIDIA NIM | ⚠️ 谨慎 | 试用条款 §1.2 / §1.4:*“仅供评估,不用于生产。”* 免费访问是持续的 40 RPM 限流(2025 年的积分制已停止),但仅供评估的范围依然有效。 |-| GitHub Models | ⚠️ 谨慎 | 免费层明确限定为*“实验”*和*“原型验证”*。 || Cohere | ❌ 避免 | 条款 §14 仍禁止*“个人、家庭或家用目的”*。 || 智谱(open.bigmodel.cn) | ✅ 大概率可以 | 平台文档中仍保留个人、非商业研究的豁免。 || Z.ai(api.z.ai) | ⚠️ 谨慎 | 新条目 —— 新加坡实体(与智谱中国不同)。§III.3(l) 的反流量重定向条款有可能被解读为针对代理;没有明确的个人使用豁免。 |diff --git a/docs/zh-cn/architecture/03-streaming-pipeline.md b/docs/zh-cn/architecture/03-streaming-pipeline.mdindex 99ec3c4e..9a9c4e86 100644--- a/docs/zh-cn/architecture/03-streaming-pipeline.md+++ b/docs/zh-cn/architecture/03-streaming-pipeline.md@@ -231,7 +231,6 @@ Codex CLI 和 Agents SDK 说 **Responses API**(有状态、`previous_response_| `rememberReasoning(sessionKey, modelKey, reasoning)` | 按会话存轨迹 || `rescueInlineToolCalls(text, tools)` | 内联方言 → 结构化 `tool_calls` || `repairToolArguments(args, schemas)` | 对请求 schema 修双重编码 JSON |-| `truncateMessagesForGithub(messages)` | 裁历史到 GitHub Models 输入天花板 || `normalizeOutboundContent(chunk)` | 提供方专属响应归一化 || `sanitizeResponse(chunk)` | 从流式帧脱敏机密 |diff --git a/docs/zh-cn/providers/01-supported-platforms.md b/docs/zh-cn/providers/01-supported-platforms.mdindex c819f535..479587a8 100644--- a/docs/zh-cn/providers/01-supported-platforms.md+++ b/docs/zh-cn/providers/01-supported-platforms.md@@ -23,7 +23,6 @@| `mistral` | Mistral | 带密钥 | OpenAI 兼容 | `api.mistral.ai/v1`。 || `sambanova` | SambaNova | 已退役(V23) | 未注册 | 免费额度永久消失;因历史密钥行而保留在类型联合中。 || `openrouter` | OpenRouter | 带密钥 | OpenAI 兼容 | 发送 `HTTP-Referer`/`X-Title` 头;`:free` 模型后缀标记零成本路由。 |-| `github` | GitHub Models | 带密钥 | OpenAI 兼容 | 路由到 `models.github.ai/inference`;目录使用 `<publisher>/<model>` 形式的 id。 || `cohere` | Cohere | 带密钥 | 原生(`CohereProvider`) | 使用 Cohere 的 OpenAI 兼容端点。 || `cloudflare` | Cloudflare Workers AI | 带密钥(`account_id:token`) | 原生(`CloudflareProvider`) | 复合凭据格式由适配器解析。 || `zhipu` | Zhipu (Z.ai / bigmodel.cn) | 带密钥 | 原生(`ZhipuProvider`) | 控制台自动探测:国内密钥被拒后会改向全球 `api.z.ai` 主机重新探测;60s 超时覆盖 glm-4.7-flash 的隐藏推理。 |diff --git a/server/src/__tests__/db/idempotency.test.ts b/server/src/__tests__/db/idempotency.test.tsindex fe8bbd2f..1050e11f 100644--- a/server/src/__tests__/db/idempotency.test.ts+++ b/server/src/__tests__/db/idempotency.test.ts@@ -192,16 +192,13 @@ describe('Migration idempotency', () => {]);});- it('caps GitHub GPT-4.1 at the routable free-tier context window (#426)', () => {+ it('removes the retired GitHub Models provider (#1557)', () => {process.env.ENCRYPTION_KEY = '0'.repeat(64);const db = initDb(':memory:');- const row = db.prepare(`- SELECT context_window FROM models- WHERE platform = 'github' AND model_id = 'openai/gpt-4.1'- `).get() as { context_window: number };-- expect(row.context_window).toBe(8000);+ for (const table of ['models', 'embedding_models', 'api_keys']) {+ expect((db.prepare(`SELECT COUNT(*) AS n FROM ${table} WHERE platform = 'github'`).get() as { n: number }).n).toBe(0);+ }});it('V14: cerebras deprecation disables qwen-3-235b and llama3.1-8b but keeps gpt-oss-120b enabled', () => {diff --git a/server/src/__tests__/db/intelligence-tiers.test.ts b/server/src/__tests__/db/intelligence-tiers.test.tsindex 58c14b3a..f18d1ff6 100644--- a/server/src/__tests__/db/intelligence-tiers.test.ts+++ b/server/src/__tests__/db/intelligence-tiers.test.ts@@ -43,7 +43,6 @@ describe('intelligence tier audit (migrateModelsV17)', () => {it('demotes lapped models down from Large', () => {expect(tier('google', 'gemini-2.5-flash')).toBe('Medium'); // AA 21- expect(tier('github', 'gpt-4o')).toBe('Medium'); // AA 17expect(tier('cohere', 'command-a-03-2025')).toBe('Medium'); // AA 13expect(tier('ollama', 'devstral-2:123b')).toBe('Medium'); // AA 22});diff --git a/server/src/__tests__/db/migrate/endpoint-identity.test.ts b/server/src/__tests__/db/migrate/endpoint-identity.test.tsindex 8192b9aa..81377ea5 100644--- a/server/src/__tests__/db/migrate/endpoint-identity.test.ts+++ b/server/src/__tests__/db/migrate/endpoint-identity.test.ts@@ -74,7 +74,8 @@ describe('custom model endpoint identity migration', () => {).all(seededProfileId, seededModelId);const fallbackBefore = chainOf();const profileBefore = profileOf();- const totalBefore = (db.prepare('SELECT COUNT(*) AS n FROM models').get() as { n: number }).n;+ const countModels = () => (db.prepare("SELECT COUNT(*) AS n FROM models WHERE platform != 'github'").get() as { n: number }).n;+ const totalBefore = countModels();await runMigrations(db, 'up');@@ -87,9 +88,9 @@ describe('custom model endpoint identity migration', () => {expect(chainOf()).toEqual(fallbackBefore);expect(profileOf()).toEqual(profileBefore);expect(db.pragma('foreign_key_check')).toEqual([]);- // Nothing was dropped on the way through (later migrations only add rows).- expect((db.prepare('SELECT COUNT(*) AS n FROM models').get() as { n: number }).n)- .toBeGreaterThanOrEqual(totalBefore);+ // Nothing was dropped on the way through: later migrations only add rows,+ // apart from the retired GitHub provider's (#1557).+ expect(countModels()).toBeGreaterThanOrEqual(totalBefore);} finally {db.close();}diff --git a/server/src/__tests__/db/migrate/remove-github-provider.test.ts b/server/src/__tests__/db/migrate/remove-github-provider.test.tsnew file mode 100644index 00000000..d7bb1f24--- /dev/null+++ b/server/src/__tests__/db/migrate/remove-github-provider.test.ts@@ -0,0 +1,62 @@+import Database from 'better-sqlite3';+import { afterEach, describe, expect, it } from 'vitest';+import { runMigrations } from '../../../db/migrate/runner.js';+import { up, down } from '../../../db/migrations/20261017_000002_remove_github_provider.js';++// GitHub Models was retired upstream (#549); leftover keys looked healthy and+// custom GitHub models still joined the chain (#1557).++const dbs: Database.Database[] = [];+afterEach(() => {+ for (const db of dbs.splice(0)) db.close();+});++async function migratedDb(): Promise<Database.Database> {+ const db = new Database(':memory:');+ dbs.push(db);+ await runMigrations(db, 'up');+ return db;+}++function githubCounts(db: Database.Database) {+ const count = (sql: string) => (db.prepare(sql).get() as { n: number }).n;+ return {+ keys: count("SELECT COUNT(*) AS n FROM api_keys WHERE platform = 'github'"),+ models: count("SELECT COUNT(*) AS n FROM models WHERE platform = 'github'"),+ chain: count("SELECT COUNT(*) AS n FROM fallback_config WHERE model_db_id IN (SELECT id FROM models WHERE platform = 'github')"),+ };+}++describe('remove_github_provider migration (#1557)', () => {+ it('removes a leftover GitHub key and custom model, keeps other providers, and DOWN restores them', async () => {+ const db = await migratedDb();+ // The state a user upgrading from 0.15.0 has: a GitHub key and a custom+ // GitHub model in the fallback chain.+ const keyId = Number(db.prepare(`+ INSERT INTO api_keys (platform, label, encrypted_key, iv, auth_tag, status, enabled)+ VALUES ('github', 'gh', 'enc', 'iv', 'tag', 'healthy', 1)+ `).run().lastInsertRowid);+ const modelId = Number(db.prepare(`+ INSERT INTO models (platform, model_id, display_name, intelligence_rank, speed_rank, enabled, source)+ VALUES ('github', 'openai/gpt-4.1', 'GPT-4.1', 20, 7, 1, 'user')+ `).run().lastInsertRowid);+ db.prepare('INSERT INTO fallback_config (model_db_id, priority, enabled) VALUES (?, 999, 1)').run(modelId);+ db.prepare(`+ INSERT INTO api_keys (platform, label, encrypted_key, iv, auth_tag, status, enabled)+ VALUES ('groq', 'groq', 'enc', 'iv', 'tag', 'healthy', 1)+ `).run();+ const otherModels = (db.prepare("SELECT COUNT(*) AS n FROM models WHERE platform != 'github'").get() as { n: number }).n;++ up(db);+ expect(githubCounts(db)).toEqual({ keys: 0, models: 0, chain: 0 });+ expect(db.prepare("SELECT COUNT(*) AS n FROM api_keys WHERE platform = 'groq'").get()).toEqual({ n: 1 });+ expect((db.prepare("SELECT COUNT(*) AS n FROM models WHERE platform != 'github'").get() as { n: number }).n).toBe(otherModels);+ expect(db.pragma('foreign_key_check')).toEqual([]);++ down(db);+ expect(githubCounts(db)).toEqual({ keys: 1, models: 1, chain: 1 });+ expect(db.prepare('SELECT id, status, enabled FROM api_keys WHERE platform = ?').get('github'))+ .toEqual({ id: keyId, status: 'healthy', enabled: 1 });+ expect(db.prepare("SELECT value FROM settings WHERE key = 'migration_github_removed_rows'").get()).toBeUndefined();+ });+});diff --git a/server/src/__tests__/db/migrate/roundtrip.test.ts b/server/src/__tests__/db/migrate/roundtrip.test.tsindex b5cd1da8..f549c9da 100644--- a/server/src/__tests__/db/migrate/roundtrip.test.ts+++ b/server/src/__tests__/db/migrate/roundtrip.test.ts@@ -46,6 +46,7 @@ const CUSTOM_ENDPOINT_GROUP_LABEL_FILENAME = '20260930_000001_custom_endpoint_grconst SEARCH_ENGINES_FILENAME = '20261013_000001_search_engines.ts';const DECISION_REQUESTS_FILENAME = '20261016_000001_decision_requests.ts';const LLMTR_REENABLE_KEYS_FILENAME = '20261017_000001_llmtr_reenable_keys.ts';+const REMOVE_GITHUB_PROVIDER_FILENAME = '20261017_000002_remove_github_provider.ts';interface SchemaRow {type: string;@@ -138,6 +139,7 @@ describe('migration round trip', () => {SEARCH_ENGINES_FILENAME,DECISION_REQUESTS_FILENAME,LLMTR_REENABLE_KEYS_FILENAME,+ REMOVE_GITHUB_PROVIDER_FILENAME,]);} finally {db.close();diff --git a/server/src/__tests__/lib/content.test.ts b/server/src/__tests__/lib/content.test.tsindex cfb10c0f..a65e9929 100644--- a/server/src/__tests__/lib/content.test.ts+++ b/server/src/__tests__/lib/content.test.ts@@ -1,5 +1,5 @@import { describe, it, expect } from 'vitest';-import { GITHUB_MAX_INPUT_TOKENS, contentToString, estimateInputTokens, flattenMessageContent, messageHasImage, normalizeOutboundContent, sanitizeResponse, stripImagesFromMessages, truncateMessagesForGithub } from '../../lib/content.js';+import { contentToString, estimateInputTokens, flattenMessageContent, messageHasImage, normalizeOutboundContent, sanitizeResponse, stripImagesFromMessages } from '../../lib/content.js';import type { ChatMessage } from '@freellmapi/shared/types.js';describe('contentToString', () => {@@ -204,73 +204,6 @@ describe('sanitizeResponse', () => {});});-describe('truncateMessagesForGithub', () => {- const msg = (role: ChatMessage['role'], content: string): ChatMessage => ({ role, content });- // ~4000 tokens each under the chars/4 estimate the gateway uses everywhere.- const big = (c: string) => c.repeat(16000);-- it('returns the same array when the request already fits', () => {- const messages = [msg('system', 'be brief'), msg('user', 'hi')];- expect(truncateMessagesForGithub(messages)).toBe(messages);- });-- it('leaves an empty list alone', () => {- const messages: ChatMessage[] = [];- expect(truncateMessagesForGithub(messages)).toBe(messages);- });-- it('drops the oldest turns, keeping the system prompt and the newest context', () => {- const messages = [- msg('system', 'be brief'),- msg('user', big('a')),- msg('assistant', big('b')),- msg('user', big('c')),- msg('user', 'the actual question'),- ];- const out = truncateMessagesForGithub(messages);- expect(out).not.toBe(messages);- expect(out[0]).toBe(messages[0]);- expect(out[out.length - 1].content).toBe('the actual question');- // Only one of the ~4000-token turns fits alongside the newest question.- expect(out.map(m => m.content)).not.toContain(big('a'));- expect(out.map(m => m.content)).toContain(big('c'));- const total = out.reduce((sum, m) => sum + Math.ceil(String(m.content).length / 4), 0);- expect(total).toBeLessThanOrEqual(GITHUB_MAX_INPUT_TOKENS);- });-- it('keeps the system prompt verbatim wherever it sits in the list', () => {- const system = msg('system', 'be brief');- const messages = [msg('user', big('a')), system, msg('user', big('b'))];- const out = truncateMessagesForGithub(messages);- expect(out[0]).toBe(system);- });-- it('truncates a single oversized message instead of sending nothing', () => {- const out = truncateMessagesForGithub([msg('user', big('y').repeat(3))]);- expect(out).toHaveLength(1);- expect(String(out[0].content).length).toBe(GITHUB_MAX_INPUT_TOKENS * 4);- });-- it('reserves the system prompt budget when truncating the newest message', () => {- const system = msg('system', 'x'.repeat(400)); // 100 tokens- const out = truncateMessagesForGithub([system, msg('user', big('z').repeat(3))]);- expect(out[0]).toBe(system);- expect(String(out[1].content).length).toBe((GITHUB_MAX_INPUT_TOKENS - 100) * 4);- });-- it('honours a caller-supplied budget', () => {- const messages = [msg('user', 'one'), msg('user', 'two'), msg('user', 'the newest')];- const out = truncateMessagesForGithub(messages, 3); // 12 chars of room- expect(out.map(m => m.content)).toEqual(['the newest']);- });-- it('never rewrites multimodal content, only drops whole messages', () => {- const image: ChatMessage = { role: 'user', content: [{ type: 'image_url', image_url: { url: 'data:x' } }] } as ChatMessage;- const out = truncateMessagesForGithub([msg('user', big('a')), image], 1);- expect(out).toEqual([image]);- });-});-describe('estimateInputTokens', () => {const messages: ChatMessage[] = [{ role: 'user', content: 'x'.repeat(400) }];diff --git a/server/src/__tests__/lib/sampling-params.test.ts b/server/src/__tests__/lib/sampling-params.test.tsindex cfa8aa94..05f1720d 100644--- a/server/src/__tests__/lib/sampling-params.test.ts+++ b/server/src/__tests__/lib/sampling-params.test.ts@@ -148,7 +148,6 @@ describe('reasoning_effort (request-side reasoning control)', () => {it('forwarded verbatim on openai-compat platforms without a droplist entry', () => {expect(extendedBodyParams('groq', { reasoning_effort: 'medium' }).reasoning_effort).toBe('medium');expect(extendedBodyParams('cerebras', { reasoning_effort: 'none' }).reasoning_effort).toBe('none');- expect(extendedBodyParams('github', { reasoning_effort: 'high' }).reasoning_effort).toBe('high');});it('stripped for platforms with no support (never 400s a strict upstream)', () => {@@ -206,10 +205,7 @@ describe('reasoning_effort normalization (#619 — off-scale values must not 400expect(pickSamplingParams({ reasoning_effort: 'nonsense', seed: 3 })).toEqual({ seed: 3 });});- it('per-platform clamping: github and groq take only low/medium/high', () => {- expect(extendedBodyParams('github', { reasoning_effort: 'none' }).reasoning_effort).toBe('low');- expect(extendedBodyParams('github', { reasoning_effort: 'minimal' }).reasoning_effort).toBe('low');- expect(extendedBodyParams('github', { reasoning_effort: 'medium' }).reasoning_effort).toBe('medium');+ it('per-platform clamping: groq takes only low/medium/high', () => {// Groq's enum is the same three values, so 'none'/'minimal' are clamped// instead of being sent and 400ing the request off the platform.expect(extendedBodyParams('groq', { reasoning_effort: 'none' }).reasoning_effort).toBe('low');diff --git a/server/src/__tests__/lib/unified-max-tokens.test.ts b/server/src/__tests__/lib/unified-max-tokens.test.tsindex 0c7de2aa..7a8b032f 100644--- a/server/src/__tests__/lib/unified-max-tokens.test.ts+++ b/server/src/__tests__/lib/unified-max-tokens.test.ts@@ -17,11 +17,13 @@ import {resolveMaxTokens,defaultMaxTokensFor,maxTokensCapFor,- GITHUB_MAX_OUTPUT_TOKENS,UNIFIED_MAX_TOKENS_SETTING,UNIFIED_MAX_TOKENS_AUTO,} from '../../lib/sampling-params.js';+// Moondream's documented output ceiling (PLATFORM_PARAM_POLICIES.moondream).+const MOONDREAM_MAX_OUTPUT_TOKENS = 4096;+beforeEach(() => {settingStore.clear();});@@ -100,32 +102,32 @@ describe('resolveMaxTokens under the cap', () => {describe('per-platform max_tokens ceiling', () => {it('is declared only for platforms whose API rejects large values', () => {- expect(maxTokensCapFor('github')).toBe(GITHUB_MAX_OUTPUT_TOKENS);+ expect(maxTokensCapFor('moondream')).toBe(MOONDREAM_MAX_OUTPUT_TOKENS);expect(maxTokensCapFor('groq')).toBeUndefined();expect(maxTokensCapFor('nonsense-platform')).toBeUndefined();});it('clamps an oversized request even with the operator cap off', () => {expect(unifiedMaxTokensCap()).toBeNull();- expect(resolveMaxTokens('github', 65536)).toBe(GITHUB_MAX_OUTPUT_TOKENS);+ expect(resolveMaxTokens('moondream', 65536)).toBe(MOONDREAM_MAX_OUTPUT_TOKENS);// Other platforms keep the historical pass-through behaviour.expect(resolveMaxTokens('groq', 65536)).toBe(65536);});it('leaves a request at or below the platform ceiling alone', () => {- expect(resolveMaxTokens('github', 128)).toBe(128);- expect(resolveMaxTokens('github', GITHUB_MAX_OUTPUT_TOKENS)).toBe(GITHUB_MAX_OUTPUT_TOKENS);+ expect(resolveMaxTokens('moondream', 128)).toBe(128);+ expect(resolveMaxTokens('moondream', MOONDREAM_MAX_OUTPUT_TOKENS)).toBe(MOONDREAM_MAX_OUTPUT_TOKENS);});it('sends nothing when the client sent nothing and the platform has no floor', () => {- expect(resolveMaxTokens('github', undefined)).toBeUndefined();+ expect(resolveMaxTokens('moondream', undefined)).toBeUndefined();});it('takes the tighter of the platform ceiling and the operator cap', () => {settingStore.set(UNIFIED_MAX_TOKENS_SETTING, 'auto'); // 32768 — looser- expect(resolveMaxTokens('github', 65536)).toBe(GITHUB_MAX_OUTPUT_TOKENS);+ expect(resolveMaxTokens('moondream', 65536)).toBe(MOONDREAM_MAX_OUTPUT_TOKENS);settingStore.set(UNIFIED_MAX_TOKENS_SETTING, '128'); // tighter than the platform- expect(resolveMaxTokens('github', 65536)).toBe(128);+ expect(resolveMaxTokens('moondream', 65536)).toBe(128);});});@@ -153,6 +155,6 @@ describe('contextBudget clamping', () => {it('takes the tightest of context budget, platform cap, and operator cap', () => {settingStore.set(UNIFIED_MAX_TOKENS_SETTING, '16000');- expect(resolveMaxTokens('github', 64000, 48000)).toBe(Math.min(GITHUB_MAX_OUTPUT_TOKENS, 16000, 48000));+ expect(resolveMaxTokens('moondream', 64000, 48000)).toBe(Math.min(MOONDREAM_MAX_OUTPUT_TOKENS, 16000, 48000));});});diff --git a/server/src/__tests__/providers/openai-compat.test.ts b/server/src/__tests__/providers/openai-compat.test.tsindex 5d235a8d..2bb281cc 100644--- a/server/src/__tests__/providers/openai-compat.test.ts+++ b/server/src/__tests__/providers/openai-compat.test.ts@@ -405,6 +405,27 @@ describe('OpenAICompatProvider', () => {expect(await provider.validateKey('valid')).toBe(true);});+ it('validateKey treats a 200 that is not JSON as an error, not a healthy key (#1557)', async () => {+ // Retired GitHub Models answered every path with 200 "OK" in plain text.+ vi.spyOn(global, 'fetch').mockResolvedValueOnce({+ ok: true,+ status: 200,+ headers: new Headers({ 'content-type': 'text/plain' }),+ text: () => Promise.resolve('OK\n'),+ } as any);+ await expect(provider.validateKey('any')).rejects.toThrow(/did not answer JSON/);+ });++ it('validateKey accepts a JSON model list', async () => {+ vi.spyOn(global, 'fetch').mockResolvedValueOnce({+ ok: true,+ status: 200,+ headers: new Headers({ 'content-type': 'application/json' }),+ text: () => Promise.resolve('{"object":"list","data":[]}'),+ } as any);+ expect(await provider.validateKey('valid')).toBe(true);+ });+it('validateKey preserves the provider reason on confirmed 401', async () => {vi.spyOn(global, 'fetch').mockResolvedValueOnce({ok: false,diff --git a/server/src/__tests__/routes/fallback.test.ts b/server/src/__tests__/routes/fallback.test.tsindex a8a4f047..e27d7a20 100644--- a/server/src/__tests__/routes/fallback.test.ts+++ b/server/src/__tests__/routes/fallback.test.ts@@ -68,7 +68,8 @@ describe('Fallback API', () => {const db = getDb();const target = db.prepare(`SELECT id, platform, model_id FROM models- WHERE platform = 'github' AND model_id = 'openai/gpt-4.1'+ WHERE platform = 'groq'+ ORDER BY id LIMIT 1`).get() as { id: number; platform: string; model_id: string };const other = db.prepare(`SELECT platform, model_id FROM modelsdiff --git a/server/src/__tests__/routes/proxy-github-limits.test.ts b/server/src/__tests__/routes/proxy-github-limits.test.tsdeleted file mode 100644index 5b2699e0..00000000--- a/server/src/__tests__/routes/proxy-github-limits.test.ts+++ /dev/null@@ -1,131 +0,0 @@-import { describe, it, expect, beforeAll, beforeEach, afterEach, vi } from 'vitest';-import type { Express } from 'express';-import { createApp } from '../../app.js';-import { initDb, getDb, getUnifiedApiKey } from '../../db/index.js';-import { GITHUB_MAX_INPUT_TOKENS } from '../../lib/content.js';-import { GITHUB_MAX_OUTPUT_TOKENS } from '../../lib/sampling-params.js';-import { mintDashboardToken } from '../helpers/auth.js';--// GitHub Models is the strictest free platform in the catalog: it 400s on a-// max_tokens above its own ceiling and 413s on a long history instead of-// truncating it. Both are pre-dispatch rejections, so without these guards a-// github hop is a guaranteed wasted attempt on every oversized request — and-// the same oversized body rides the rest of the chain.--let dashToken = '';--async function request(app: Express, path: string, body: any, headers: Record<string, string>) {- const server = app.listen(0, '127.0.0.1');- if (!server.listening) await new Promise<void>(resolve => server.once('listening', () => resolve()));- const addr = server.address() as any;- const res = await fetch(`http://127.0.0.1:${addr.port}${path}`, {- method: 'POST',- headers: { 'Content-Type': 'application/json', ...headers },- body: JSON.stringify(body),- });- const text = await res.text();- server.close();- let json: any = null;- try { json = JSON.parse(text); } catch { /* SSE body */ }- return { status: res.status, body: json };-}--describe('github platform limits', () => {- let app: Express;- const sent: any[] = [];-- beforeAll(() => {- process.env.ENCRYPTION_KEY = '0'.repeat(64);- initDb(':memory:');- app = createApp();- dashToken = mintDashboardToken();- });-- beforeEach(async () => {- const db = getDb();- db.prepare('DELETE FROM api_keys').run();- db.prepare('DELETE FROM requests').run();- db.prepare('DELETE FROM rate_limit_cooldowns').run();- db.prepare('DELETE FROM rate_limit_usage').run();- sent.length = 0;- // Only a github key, so every route the chain can pick is a github one.- const { status } = await request(app, '/api/keys',- { platform: 'github', key: 'ghp_github_limits_test', label: 't' },- { Authorization: `Bearer ${dashToken}` });- expect(status).toBe(201);-- const origFetch = global.fetch;- vi.spyOn(global, 'fetch').mockImplementation(async (url, init) => {- const urlStr = typeof url === 'string' ? url : url.toString();- if (!urlStr.includes('models.github.ai')) return origFetch(url as any, init);- sent.push(JSON.parse(String((init as RequestInit).body)));- return new Response(JSON.stringify({- id: 'gh1', object: 'chat.completion', created: 1, model: 'gpt-4o',- choices: [{ index: 0, message: { role: 'assistant', content: 'ok' }, finish_reason: 'stop' }],- usage: { prompt_tokens: 10, completion_tokens: 1, total_tokens: 11 },- }), { status: 200, headers: { 'Content-Type': 'application/json' } });- });- });-- afterEach(() => {- vi.restoreAllMocks();- });-- it('clamps an aggressive max_tokens to the platform ceiling instead of 400ing', async () => {- const r = await request(app, '/v1/chat/completions', {- model: 'gpt-4o', max_tokens: 65536,- messages: [{ role: 'user', content: 'hello' }],- }, { Authorization: `Bearer ${getUnifiedApiKey()}` });-- expect(r.status).toBe(200);- expect(sent).toHaveLength(1);- expect(sent[0].max_tokens).toBe(GITHUB_MAX_OUTPUT_TOKENS);- });-- it('trims a long history to the platform input budget before dispatch', async () => {- // 1900 tokens per turn under the chars/4 estimate: four of them plus the- // question sit above the 7500-token input budget but still inside the- // model's 8000-token context window, so routing picks github and the- // guard — not the router — is what has to shrink the request. (max_tokens- // 1 keeps the routing output reserve out of the way.)- const turn = (c: string) => c.repeat(7600);- const messages = [- { role: 'system', content: 'be brief' },- { role: 'user', content: turn('a') },- { role: 'assistant', content: turn('b') },- { role: 'user', content: turn('c') },- { role: 'assistant', content: turn('d') },- { role: 'user', content: 'the actual question' },- ];-- const r = await request(app, '/v1/chat/completions', {- model: 'gpt-4o', max_tokens: 1, messages,- }, { Authorization: `Bearer ${getUnifiedApiKey()}` });-- expect(r.status).toBe(200);- expect(sent).toHaveLength(1);- const out = sent[0].messages as Array<{ role: string; content: string }>;- // System prompt and the newest turn survive; the oldest turns are gone.- expect(out[0].role).toBe('system');- expect(out[out.length - 1].content).toBe('the actual question');- expect(out.length).toBeLessThan(messages.length);- expect(out.some(m => m.content === turn('a'))).toBe(false);- const tokens = out.reduce((sum, m) => sum + Math.ceil(m.content.length / 4), 0);- expect(tokens).toBeLessThanOrEqual(GITHUB_MAX_INPUT_TOKENS);- });-- it('leaves a history that already fits untouched', async () => {- const messages = [- { role: 'system', content: 'be brief' },- { role: 'user', content: 'first' },- { role: 'assistant', content: 'second' },- { role: 'user', content: 'third' },- ];- const r = await request(app, '/v1/chat/completions', {- model: 'gpt-4o', max_tokens: 1, messages,- }, { Authorization: `Bearer ${getUnifiedApiKey()}` });-- expect(r.status).toBe(200);- expect(sent[0].messages.map((m: any) => m.content)).toEqual(messages.map(m => m.content));- });-});diff --git a/server/src/__tests__/services/builtin-model-discovery.test.ts b/server/src/__tests__/services/builtin-model-discovery.test.tsindex 66f512b7..26249499 100644--- a/server/src/__tests__/services/builtin-model-discovery.test.ts+++ b/server/src/__tests__/services/builtin-model-discovery.test.ts@@ -136,15 +136,6 @@ describe('built-in model discovery (#1348)', () => {expect(builtinDiscoveryEligibility(getDb(), 'longcat')).toMatchObject({ eligible: false, reason: 'catalog_managed' });});- it('is off limits while the bundled baseline still holds catalog rows for the platform', () => {- // A fresh DB seeds github rows until the first catalog sync prunes them.- const github = rows('github');- expect(github.length).toBeGreaterThan(0);- expect(builtinDiscoveryEligibility(getDb(), 'github')).toMatchObject({ eligible: false, reason: 'catalog_managed' });- getDb().exec("DELETE FROM fallback_config WHERE model_db_id IN (SELECT id FROM models WHERE platform = 'github'); DELETE FROM models WHERE platform = 'github'; DELETE FROM embedding_models WHERE platform = 'github';");- expect(builtinDiscoveryEligibility(getDb(), 'github').eligible).toBe(true);- });-it('can be switched off', () => {process.env.BUILTIN_MODEL_DISCOVERY = 'off';expect(builtinDiscoveryEligibility(getDb(), 'siliconflow')).toMatchObject({ eligible: false, reason: 'disabled' });diff --git a/server/src/__tests__/services/catalog-sync.test.ts b/server/src/__tests__/services/catalog-sync.test.tsindex 70195964..bc994366 100644--- a/server/src/__tests__/services/catalog-sync.test.ts+++ b/server/src/__tests__/services/catalog-sync.test.ts@@ -120,20 +120,6 @@ describe('applyCatalog', () => {expect(fb).toBeTruthy();});- it('caps GitHub GPT-4.1 catalog context at the routable free-tier limit (#426)', () => {- const models = existingAsCatalogModels();- const target = models.find((m) => m.platform === 'github' && m.modelId === 'openai/gpt-4.1');- expect(target).toBeDefined();- target!.contextWindow = 128000;-- applyCatalog(getDb(), catalogOf(models));-- const row = getDb()- .prepare("SELECT context_window FROM models WHERE platform = 'github' AND model_id = 'openai/gpt-4.1'")- .get() as { context_window: number };- expect(row.context_window).toBe(8000);- });-it('updates metadata in place and respects the enabled policy', () => {const models = existingAsCatalogModels();const target = models.find((m) => m.modelId === 'brand-new-model')!;diff --git a/server/src/__tests__/services/embeddings.test.ts b/server/src/__tests__/services/embeddings.test.tsindex b44d7eca..97e19cdb 100644--- a/server/src/__tests__/services/embeddings.test.ts+++ b/server/src/__tests__/services/embeddings.test.ts@@ -442,17 +442,6 @@ describe('embeddings service', () => {expect(String(fetchMock.mock.calls[0][0])).toContain('generativelanguage.googleapis.com');});- it('forwards dimensions to the github provider', async () => {- addKey('github');- const fetchMock = mockFetch(async () => okEmbeddingResponse(512));-- await runEmbeddings('text-embedding-3-small', ['hello'], 512);-- const body = JSON.parse(String((fetchMock.mock.calls[0][1] as RequestInit).body));- expect(body.dimensions).toBe(512);- expect(String(fetchMock.mock.calls[0][0])).toContain('models.github.ai');- });-it('forwards dimensions to the openrouter provider', async () => {addKey('openrouter');const fetchMock = mockFetch(async () => okEmbeddingResponse(1024));diff --git a/server/src/__tests__/services/router.test.ts b/server/src/__tests__/services/router.test.tsindex da57de9b..429290fc 100644--- a/server/src/__tests__/services/router.test.ts+++ b/server/src/__tests__/services/router.test.ts@@ -136,42 +136,6 @@ describe('Router', () => {expect(large.modelDbId).not.toBe(baseline.modelDbId);});- it('skips GitHub GPT-4.1 above its free-tier 8K request cap (#426)', () => {- const db = getDb();- const githubKey = encrypt('test-github-key');- db.prepare(`- INSERT INTO api_keys (platform, label, encrypted_key, iv, auth_tag, status, enabled)- VALUES (?, ?, ?, ?, ?, ?, ?)- `).run('github', 'github', githubKey.encrypted, githubKey.iv, githubKey.authTag, 'healthy', 1);- const groqKey = encrypt('test-groq-key');- db.prepare(`- INSERT INTO api_keys (platform, label, encrypted_key, iv, auth_tag, status, enabled)- VALUES (?, ?, ?, ?, ?, ?, ?)- `).run('groq', 'groq', groqKey.encrypted, groqKey.iv, groqKey.authTag, 'healthy', 1);-- const github = db.prepare(`- SELECT id, context_window FROM models- WHERE platform = 'github' AND model_id = 'openai/gpt-4.1'- `).get() as { id: number; context_window: number };- const groq = db.prepare(`- SELECT id FROM models- WHERE platform = 'groq' AND context_window > 9000- LIMIT 1- `).get() as { id: number };-- db.prepare('UPDATE fallback_config SET priority = 1000, enabled = 1').run();- db.prepare('UPDATE fallback_config SET priority = 1 WHERE model_db_id = ?').run(github.id);- db.prepare('UPDATE fallback_config SET priority = 2 WHERE model_db_id = ?').run(groq.id);- db.prepare(`- UPDATE models SET tpm_limit = NULL, tpd_limit = NULL- WHERE id IN (?, ?)- `).run(github.id, groq.id);-- expect(github.context_window).toBe(8000);- expect(routeRequest(7000).modelDbId).toBe(github.id);- expect(routeRequest(9000).modelDbId).toBe(groq.id);- });-it('prefers margin-fitting models but still serves raw-window fits (#956 review)', () => {const db = getDb();const groqKey = encrypt('test-groq-key');diff --git a/server/src/db/migrate/defaults.ts b/server/src/db/migrate/defaults.tsindex b5f9b9e9..c5e3c068 100644--- a/server/src/db/migrate/defaults.ts+++ b/server/src/db/migrate/defaults.ts@@ -41,6 +41,7 @@ import * as customEndpointGroupLabel from '../migrations/20260930_000001_custom_import * as searchEngines from '../migrations/20261013_000001_search_engines.js';import * as decisionRequests from '../migrations/20261016_000001_decision_requests.js';import * as llmtrReenableKeys from '../migrations/20261017_000001_llmtr_reenable_keys.js';+import * as removeGithubProvider from '../migrations/20261017_000002_remove_github_provider.js';export interface MigrationModule {up(db: Db): void;@@ -94,6 +95,7 @@ export const QUOTA_SNAPSHOT_FRESHNESS_FILENAME = '20260915_000001_quota_snapshotexport const SEARCH_ENGINES_FILENAME = '20261013_000001_search_engines.ts';export const DECISION_REQUESTS_FILENAME = '20261016_000001_decision_requests.ts';export const LLMTR_REENABLE_KEYS_FILENAME = '20261017_000001_llmtr_reenable_keys.ts';+export const REMOVE_GITHUB_PROVIDER_FILENAME = '20261017_000002_remove_github_provider.ts';export const DEFAULT_MIGRATIONS: readonly DefaultMigration[] = [{ filename: LEGACY_BASELINE_FILENAME, module: legacyBaseline },@@ -138,4 +140,5 @@ export const DEFAULT_MIGRATIONS: readonly DefaultMigration[] = [{ filename: SEARCH_ENGINES_FILENAME, module: searchEngines },{ filename: DECISION_REQUESTS_FILENAME, module: decisionRequests },{ filename: LLMTR_REENABLE_KEYS_FILENAME, module: llmtrReenableKeys },+ { filename: REMOVE_GITHUB_PROVIDER_FILENAME, module: removeGithubProvider },];diff --git a/server/src/db/migrations/20261017_000002_remove_github_provider.ts b/server/src/db/migrations/20261017_000002_remove_github_provider.tsnew file mode 100644index 00000000..a3dbc731--- /dev/null+++ b/server/src/db/migrations/20261017_000002_remove_github_provider.ts@@ -0,0 +1,92 @@+// Migration: remove the retired GitHub Models provider+// Created: 2026-10-17+//+// DOWN: reversible (the removed rows are kept in settings)+//+// GitHub Models was retired on 30 July 2026 (#549). models.github.ai now+// answers every request with 200 "OK" in plain text, so leftover GitHub keys+// looked healthy, custom GitHub models joined the fallback chain, and every+// request routed there failed (#1557). The adapter is gone, so these rows can+// never serve again: remove the keys, models, embedding and media rows, model+// overrides, and the chain and profile entries that point at the models.+// Request history keeps its 'github' rows; that is a record, not config.++import type { Db } from '../types.js';++const SETTING_KEY = 'migration_github_removed_rows';++type Row = Record<string, unknown>;++// Insert order for DOWN: parents before the rows that reference them.+const TABLES = ['api_keys', 'models', 'embedding_models', 'media_models', 'model_overrides', 'fallback_config', 'profile_models'] as const;+type Table = (typeof TABLES)[number];++function tableExists(db: Db, table: string): boolean {+ return db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(table) !== undefined;+}++function selectRows(db: Db, table: Table): Row[] {+ if (!tableExists(db, table)) return [];+ if (table === 'fallback_config' || table === 'profile_models') {+ return db.prepare(`+ SELECT * FROM ${table} WHERE model_db_id IN (SELECT id FROM models WHERE platform = 'github')+ `).all() as Row[];+ }+ return db.prepare(`SELECT * FROM ${table} WHERE platform = 'github'`).all() as Row[];+}++// Encrypted key columns may be BLOBs; JSON keeps them as tagged base64.+function encode(row: Row): Row {+ const out: Row = {};+ for (const [k, v] of Object.entries(row)) {+ out[k] = Buffer.isBuffer(v) ? { $buffer: v.toString('base64') } : v;+ }+ return out;+}++function decode(row: Row): Row {+ const out: Row = {};+ for (const [k, v] of Object.entries(row)) {+ const tagged = v as { $buffer?: string } | null;+ out[k] = tagged && typeof tagged === 'object' && typeof tagged.$buffer === 'string'+ ? Buffer.from(tagged.$buffer, 'base64')+ : v;+ }+ return out;+}++export function up(db: Db): void {+ const removed: Partial<Record<Table, Row[]>> = {};+ for (const table of TABLES) removed[table] = selectRows(db, table).map(encode);++ // Children first: chain and profile rows reference models(id).+ for (const table of ['fallback_config', 'profile_models'] as const) {+ if (!tableExists(db, table)) continue;+ db.prepare(`+ DELETE FROM ${table} WHERE model_db_id IN (SELECT id FROM models WHERE platform = 'github')+ `).run();+ }+ for (const table of ['models', 'embedding_models', 'media_models', 'model_overrides', 'api_keys'] as const) {+ if (!tableExists(db, table)) continue;+ db.prepare(`DELETE FROM ${table} WHERE platform = 'github'`).run();+ }++ db.prepare(`+ INSERT INTO settings (key, value) VALUES (?, ?)+ ON CONFLICT(key) DO UPDATE SET value = excluded.value+ `).run(SETTING_KEY, JSON.stringify(removed));+}++export function down(db: Db): void {+ const row = db.prepare('SELECT value FROM settings WHERE key = ?').get(SETTING_KEY) as { value: string } | undefined;+ const removed: Partial<Record<Table, Row[]>> = row ? JSON.parse(row.value) : {};+ for (const table of TABLES) {+ for (const raw of removed[table] ?? []) {+ const r = decode(raw);+ const cols = Object.keys(r);+ db.prepare(`INSERT OR IGNORE INTO ${table} (${cols.join(', ')}) VALUES (${cols.map(() => '?').join(', ')})`)+ .run(...cols.map(c => r[c]));+ }+ }+ db.prepare('DELETE FROM settings WHERE key = ?').run(SETTING_KEY);+}diff --git a/server/src/db/model-pricing.ts b/server/src/db/model-pricing.tsindex 474f9084..695f3155 100644--- a/server/src/db/model-pricing.ts+++ b/server/src/db/model-pricing.ts@@ -45,11 +45,6 @@ export const MODEL_PRICING: PricingRow[] = [['cohere', 'command-r-08-2024', 0.15, 0.60],['cohere', 'command-r-plus-08-2024', 2.50, 10.00],- // GitHub Models (OpenAI official prices)- ['github', 'gpt-4o', 2.50, 10.00],- ['github', 'openai/gpt-4.1', 2.00, 8.00],- ['github', 'openai/gpt-5', 1.25, 10.00], // legacy-// Google AI Studio (official prices)['google', 'gemini-2.5-flash', 0.30, 2.50],['google', 'gemini-2.5-flash-lite', 0.10, 0.40],diff --git a/server/src/lib/content.ts b/server/src/lib/content.tsindex e2c1eed7..c2411248 100644--- a/server/src/lib/content.ts+++ b/server/src/lib/content.ts@@ -88,75 +88,6 @@ export function stripImagesFromMessages(messages: ChatMessage[]): ChatMessage[]});}-// GitHub Models refuses a long history outright (413) rather than truncating-// it the way most providers do, so an oversized body turns every github hop in-// the fallback chain into a wasted attempt. 7500 is the input budget we trim-// to: comfortably inside the ~8000-token ceiling observed live, with room for-// the tool schemas and the system prompt the gateway prepends.-export const GITHUB_MAX_INPUT_TOKENS = 7500;--// The proxy's own chars/4 input estimate, per message — same arithmetic the-// routing/budget paths use, so the guard below trims against the number the-// rest of the gateway reasons about.-function estimateMessageTokens(message: ChatMessage): number {- return Math.ceil(contentToString(message.content).length / 4);-}--// Trim one message's text down to a token budget. Non-string content-// (multimodal envelopes) is returned untouched — dropping or rewriting image-// blocks here would corrupt the envelope, and text is the only thing this-// guard is allowed to shorten.-function truncateMessageText(message: ChatMessage, budget: number): ChatMessage {- if (typeof message.content !== 'string') return message;- const maxChars = Math.max(0, budget) * 4;- return message.content.length <= maxChars- ? message- : { ...message, content: message.content.slice(0, maxChars) };-}--/**- * Fit a message list inside GitHub Models' input ceiling before dispatch.- * Keeps the leading system prompt verbatim (its instructions are the whole- * point of prepending one) and then as many of the NEWEST messages as the- * remaining budget allows, dropping the oldest turns first — the same trade a- * client's own context window makes. A single message that blows the budget on- * its own is truncated rather than dropped, so the turn is never dispatched- * with nothing to answer.- *- * Returns the ORIGINAL array when the request already fits, which is both the- * common case and the cheap one: callers can hand every github-routed request- * through here without copying anything.- */-export function truncateMessagesForGithub(- messages: ChatMessage[],- budget: number = GITHUB_MAX_INPUT_TOKENS,-): ChatMessage[] {- if (messages.length === 0) return messages;- const total = messages.reduce((sum, m) => sum + estimateMessageTokens(m), 0);- if (total <= budget) return messages;-- const systemIdx = messages.findIndex(m => m.role === 'system');- const systemMessage = systemIdx >= 0 ? messages[systemIdx] : null;- const rest = messages.filter((_, i) => i !== systemIdx);-- const systemTokens = systemMessage ? estimateMessageTokens(systemMessage) : 0;- let used = systemTokens;- const kept: ChatMessage[] = [];- // Newest → oldest: the most recent context is the context the answer needs.- for (let i = rest.length - 1; i >= 0; i--) {- const tokens = estimateMessageTokens(rest[i]);- if (used + tokens > budget) break;- kept.unshift(rest[i]);- used += tokens;- }- // Nothing fit alongside the system prompt: keep the newest message in- // truncated form instead of sending an empty conversation.- if (kept.length === 0 && rest.length > 0) {- kept.push(truncateMessageText(rest[rest.length - 1], budget - systemTokens));- }- return systemMessage ? [systemMessage, ...kept] : kept;-}-// Harden the OUTBOUND envelope so strict OpenAI clients don't choke on the// shape variations free-tier providers emit. Complements normalizeOutboundContent// (which fixes array content) by fixing the *frame* fields, not the content:diff --git a/server/src/lib/key-parser.ts b/server/src/lib/key-parser.tsindex e2c20e68..078062c7 100644--- a/server/src/lib/key-parser.ts+++ b/server/src/lib/key-parser.ts@@ -95,7 +95,6 @@ export const PREFIX_MAP: Record<string, string> = {NVIDIA_: 'nvidia',MISTRAL_: 'mistral',OPENROUTER_: 'openrouter',- GITHUB_: 'github',COHERE_: 'cohere',TAVILY_: 'tavily',EXA_: 'exa',diff --git a/server/src/lib/sampling-params.ts b/server/src/lib/sampling-params.tsindex 0262a6b3..20b78daa 100644--- a/server/src/lib/sampling-params.ts+++ b/server/src/lib/sampling-params.ts@@ -16,8 +16,7 @@// Forward-by-default: most OpenAI-compatible providers ignore unknown body// fields, so the default is to send everything and let the per-platform// droplist name the documented exceptions (Mistral 422s on unknown keys,-// Groq 400s on the logprobs family, Azure-backed GitHub Models rejects-// non-Azure knobs). A provider that still 400s fails over like any other+// Groq 400s on the logprobs family). A provider that still 400s fails over like any other// provider-invalid request and shows up in the attempt trail — and its// droplist entry is one line to add.@@ -233,11 +232,6 @@ export interface PlatformParamPolicy {maxTokensCap?: number;}-/** GitHub Models' own output-token ceiling: asking for more 400s ("max_tokens- * is too large"), so the request never reaches the model. Wired into the- * github policy below as maxTokensCap. */-export const GITHUB_MAX_OUTPUT_TOKENS = 400;-// Keyed by Platform (not string) so a typo'd platform id fails tsc instead of// silently no-op'ing the policy; the string-typed accessors below cast at the// boundary since routes carry platform ids as plain strings.@@ -274,7 +268,7 @@ export const PLATFORM_PARAM_POLICIES: Partial<Record<Platform, PlatformParamPoli},// Groq documents logprobs / top_logprobs / logit_bias as unsupported and// rejects requests that include them. Its reasoning_effort enum is the plain- // low/medium/high one as well: 'none' and 'minimal' are rejected with a 400+ // low/medium/high one: 'none' and 'minimal' are rejected with a 400// ("must be one of low, medium, or high", observed on openai/gpt-oss-120b),// which cost the request a fallback hop onto another platform's copy of the// same model. Clamped rather than dropped so the knob still arrives, at the@@ -283,17 +277,6 @@ export const PLATFORM_PARAM_POLICIES: Partial<Record<Platform, PlatformParamPolidrop: ['logprobs', 'top_logprobs', 'logit_bias'],reasoningEfforts: ['low', 'medium', 'high'],},- // GitHub Models sits on Azure OpenAI, which 400s "Unrecognized request- // argument" for knobs outside the OpenAI set. Its reasoning_effort enum is- // the older low/medium/high one, so 'none'/'minimal' are clamped rather- // than sent. Its free tier also refuses any max_tokens above- // GITHUB_MAX_OUTPUT_TOKENS, so the cap is clamped here instead of being- // spent as a wasted fallback hop.- github: {- drop: ['top_k', 'min_p', 'repetition_penalty'],- reasoningEfforts: ['low', 'medium', 'high'],- maxTokensCap: GITHUB_MAX_OUTPUT_TOKENS,- },// Gemini's generationConfig has no equivalents for these; the adapter// translates the rest natively (topK, seed, penalties, responseSchema, and// reasoning_effort → thinkingConfig — see toGeminiExtendedConfig).diff --git a/server/src/providers/index.ts b/server/src/providers/index.tsindex 9e7c3791..42ebcc1d 100644--- a/server/src/providers/index.ts+++ b/server/src/providers/index.ts@@ -196,14 +196,10 @@ register(new OpenAICompatProvider({},}));-// GitHub Models — OpenAI-compatible. Catalog uses `<publisher>/<model>` ids-// (e.g. `openai/gpt-4.1`); the old Azure endpoint rejects that prefix with-// "Unknown model", so route to the current models.github.ai endpoint.-register(new OpenAICompatProvider({- platform: 'github',- name: 'GitHub Models',- baseUrl: 'https://models.github.ai/inference',-}));+// GitHub Models was retired upstream on 30 July 2026 (#549): models.github.ai+// now answers every request with 200 "OK" in plain text, so a registered+// adapter only produced fake-healthy keys and broken streams (#1557). The+// provider is gone; migration 20261017_000002 removes leftover rows.// Cohere - OpenAI-compatible via Cohere compatibility endpointregister(new CohereProvider());diff --git a/server/src/providers/openai-compat.ts b/server/src/providers/openai-compat.tsindex d4fb0f38..6d5d20bc 100644--- a/server/src/providers/openai-compat.ts+++ b/server/src/providers/openai-compat.ts@@ -602,6 +602,20 @@ export class OpenAICompatProvider extends BaseProvider {async validateKey(apiKey: string, quotaContext?: QuotaObservationContext): Promise<KeyValidationResult> {const res = await this.fetchCatalogEndpoint(this.validateUrl ?? this.modelsUrl, apiKey, quotaContext);+ // An OpenAI-compatible /models answers JSON. A 200 with anything else is a+ // shut-down or parked service, not a working key: retired GitHub Models+ // answered every path with 200 "OK" in plain text and every key looked+ // healthy (#1557). Thrown, so health records an error without counting it+ // toward auto-disable. Provider-specific validate URLs keep their own shape.+ if (res.ok && !this.validateUrl && typeof res.text === 'function') {+ const text = await res.text().catch(() => '');+ try {+ JSON.parse(text);+ } catch {+ throw providerHttpError(res, `${this.name} /models did not answer JSON (got ${JSON.stringify(text.trim().slice(0, 40))}); the service may be retired or down`);+ }+ return true;+ }return this.validationResult(res);}diff --git a/server/src/routes/keys.ts b/server/src/routes/keys.tsindex 9840ee30..37523715 100644--- a/server/src/routes/keys.ts+++ b/server/src/routes/keys.ts@@ -41,7 +41,8 @@ export const keysRouter = Router();// Active providers — must match providers/index.ts registrations + shared/types.ts Platform.// Moonshot and MiniMax direct integrations were dropped in V4. HuggingFace// was dropped in V4 and re-added in V13 via the router.huggingface.co route.-// SambaNova was dropped in V23 (free tier permanently retired).+// SambaNova was dropped in V23 (free tier permanently retired). GitHub Models+// was dropped after its retirement on 30 July 2026 (#1557).const PLATFORMS = ['aclide','speka',@@ -56,7 +57,7 @@ const PLATFORMS = ['moondream','freeai','google', 'groq', 'cerebras', 'sail', 'electronhub', 'experiential', 'router9', 'septor', 'clod', 'speechify', 'blaze', 'lucidity', 'airforce', 'dreamprompting', 'waterfall', 'logfare', 'bai', 'radeon', 'nvidia', 'mistral',- 'openrouter', 'github', 'cohere', 'tavily', 'exa', 'firecrawl', 'linkup', 'parallel', 'cloudflare', 'zhipu', 'ollama',+ 'openrouter', 'cohere', 'tavily', 'exa', 'firecrawl', 'linkup', 'parallel', 'cloudflare', 'zhipu', 'ollama','kilo', 'pollinations', 'llm7', 'huggingface', 'opencode', 'ovh', 'agnes', 'reka', 'siliconflow','routeway', 'bazaarlink', 'ainative', 'aion', 'anyapi', 'requesty', 'navy', 'nara', 'sealion', 'orcarouter', 'unorouter', 'xkiro', 'modelscope','qianfan', 'volcengine', 'longcat', 'xfyun', 'aihorde', 'custom',diff --git a/server/src/routes/proxy.ts b/server/src/routes/proxy.tsindex e4d69146..d06b3520 100644--- a/server/src/routes/proxy.ts+++ b/server/src/routes/proxy.ts@@ -14,7 +14,7 @@ import { runImageGeneration, runVideoGeneration, runSpeech, runTranscription, Meimport multer from 'multer';import { getDb } from '../db/index.js';import { resolveAuth, prependSystemPrompt, type ResolvedAuth } from '../lib/system-prompt.js';-import { contentToString, estimateInputTokens, messageHasImage, normalizeOutboundContent, sanitizeResponse, truncateMessagesForGithub } from '../lib/content.js';+import { contentToString, estimateInputTokens, messageHasImage, normalizeOutboundContent, sanitizeResponse } from '../lib/content.js';import { routeOutputBudget } from '../lib/output-cap.js';import { resolveTaskType } from '../lib/task-type.js';import { normalizeMessageImages } from '../lib/image-normalize.js';@@ -1398,12 +1398,6 @@ proxyRouter.post('/completions', async (req: Request, res: Response) => {requestedModel: attempt === 0 ? requestedModelLabel : undefined,});- // Same GitHub input ceiling as /chat/completions below: trim the- // dispatched copy so a long legacy prompt doesn't 413 the github hop.- const dispatchMessages = route.platform === 'github'- ? truncateMessagesForGithub(messages)- : messages;-if (stream) {let totalOutputTokens = 0;let headerSent = false;@@ -1434,7 +1428,7 @@ proxyRouter.post('/completions', async (req: Request, res: Response) => {try {const gen = route.provider.streamChatCompletion(route.apiKey,- dispatchMessages,+ messages,route.modelId,{ temperature, max_tokens, top_p, stop, contextBudget, signal: AbortSignal.any([clientAbort.signal, hedgeAbort.signal]) },quotaContextForRoute(route, 'chat/completions'),@@ -1534,7 +1528,7 @@ proxyRouter.post('/completions', async (req: Request, res: Response) => {const result = await route.provider.chatCompletion(route.apiKey,- dispatchMessages,+ messages,route.modelId,{ temperature, max_tokens, top_p, stop, contextBudget, signal: AbortSignal.any([clientAbort.signal, hedgeAbort.signal]) },quotaContextForRoute(route, 'chat/completions'),@@ -2353,16 +2347,6 @@ proxyRouter.post('/chat/completions', async (req: Request, res: Response) => {outboundMessages = restoreSessionReasoning(outboundMessages, rememberedReasoning, route.platform);}- // GitHub Models 413s a history above its input ceiling instead of- // truncating it, so a long conversation burns the github hop of every- // chain it appears in. Trim the outbound copy to what the platform will- // accept — scoped to this attempt, so the next candidate still sees the- // client's full history. A no-op returning the same array when the- // request already fits.- if (route.platform === 'github') {- outboundMessages = truncateMessagesForGithub(outboundMessages);- }-if (stream) {// — Stream turn-integrity (#231 audit) —// The old loop forwarded upstream chunks verbatim and called anydiff --git a/server/src/services/builtin-model-discovery.ts b/server/src/services/builtin-model-discovery.tsindex c7a293fd..52536425 100644--- a/server/src/services/builtin-model-discovery.ts+++ b/server/src/services/builtin-model-discovery.ts@@ -46,7 +46,7 @@ import { customModelSyncFreePatterns, customModelSyncIntervalMs } from './custom* zero rows, enabled or disabled, in the signed live catalog (checked against* 2026.09.27). Remove a platform here in the same change that adds it to the* catalog; managedPlatforms in the catalog covers binaries already shipped. */-export const BUILTIN_DISCOVERY_PLATFORMS: readonly Platform[] = ['github', 'longcat', 'siliconflow'];+export const BUILTIN_DISCOVERY_PLATFORMS: readonly Platform[] = ['longcat', 'siliconflow'];/** `BUILTIN_MODEL_DISCOVERY`: 'manual' (default) keeps only the dashboard's* Fetch models action, so nothing is registered without the operator pickingdiff --git a/server/src/services/catalog-sync.ts b/server/src/services/catalog-sync.tsindex 6db3e113..8f969d97 100644--- a/server/src/services/catalog-sync.ts+++ b/server/src/services/catalog-sync.ts@@ -11,7 +11,6 @@ import type { Scheduler } from '../lib/scheduler.js';import {applyAllModelOverrides,refreshModelOverrideBaselines,- routableContextWindow,applyModelOverrides,deleteTombstonedCatalogModels,isCatalogModelTombstoned,@@ -571,7 +570,7 @@ function applyCatalogInner(db: Db, catalog: Catalog): NonNullable<SyncResult['cotpm: m.limits.tpm,tpd: m.limits.tpd,monthlyTokenBudget: m.monthlyTokenBudget,- contextWindow: routableContextWindow(m.platform, m.modelId, m.contextWindow),+ contextWindow: m.contextWindow,supportsVision: m.supportsVision ? 1 : 0,supportsTools: m.supportsTools ? 1 : 0,};diff --git a/server/src/services/embeddings.ts b/server/src/services/embeddings.tsindex cf7a7cd8..fdccd7af 100644--- a/server/src/services/embeddings.ts+++ b/server/src/services/embeddings.ts@@ -113,7 +113,6 @@ export const EMBEDDING_PLATFORMS = new Set(['google','nvidia','openrouter',- 'github','cloudflare','huggingface','cohere',@@ -283,8 +282,6 @@ async function callProvider(row: EmbeddingModelRow, credential: ProviderCredentireturn openAiStyleEmbed('https://integrate.api.nvidia.com/v1/embeddings', row.platform, key, row.model_id, inputs, { input_type: 'query' }, dimensions);case 'openrouter':return openAiStyleEmbed('https://openrouter.ai/api/v1/embeddings', row.platform, key, row.model_id, inputs, {}, dimensions);- case 'github':- return openAiStyleEmbed('https://models.github.ai/inference/embeddings', row.platform, key, row.model_id, inputs, {}, dimensions);case 'sealion':return openAiStyleEmbed('https://api.sea-lion.ai/v1/embeddings', row.platform, key, row.model_id, inputs, {}, dimensions);case 'speka':diff --git a/server/src/services/model-state.ts b/server/src/services/model-state.tsindex f547a51c..ddc875ef 100644--- a/server/src/services/model-state.ts+++ b/server/src/services/model-state.ts@@ -90,11 +90,6 @@ function modelRowValue(row: Record<string, unknown> | undefined, key: keyof Modereturn value ?? null;}-export function routableContextWindow(platform: string, modelId: string, contextWindow: number | null): number | null {- if (platform === 'github' && modelId === 'openai/gpt-4.1') return 8000;- return contextWindow;-}-function cachedCatalogDefaults(db: Db, platform: string, modelId: string): StoredOverrides {const row = db.prepare("SELECT value FROM settings WHERE key = 'catalog_applied_json'").get() as { value: string } | undefined;if (!row) return {};@@ -108,7 +103,7 @@ function cachedCatalogDefaults(db: Db, platform: string, modelId: string): StorerpmLimit: model.limits.rpm, rpdLimit: model.limits.rpd,tpmLimit: model.limits.tpm, tpdLimit: model.limits.tpd,monthlyTokenBudget: model.monthlyTokenBudget ?? '',- contextWindow: routableContextWindow(platform, modelId, model.contextWindow),+ contextWindow: model.contextWindow,supportsVision: model.supportsVision, supportsTools: model.supportsTools,enabled: model.enabled,};diff --git a/server/src/services/provider-quota.ts b/server/src/services/provider-quota.tsindex fb1827e0..b94a8b60 100644--- a/server/src/services/provider-quota.ts+++ b/server/src/services/provider-quota.ts@@ -141,7 +141,6 @@ export function inferPoolForPlatform(platform: Platform, modelId?: string | nullif (platform === 'sambanova') return 'sambanova::shared';if (platform === 'nvidia') return 'nvidia::credit-pool';if (platform === 'mistral') return 'mistral::experiment-pool';- if (platform === 'github') return 'github::account';if (platform === 'cohere') return 'cohere::trial-pool';if (platform === 'cloudflare') return 'cloudflare::account';if (platform === 'zhipu') return 'zhipu::account';@@ -190,7 +189,7 @@ function isSharedPool(platform: Platform): boolean {if (platform === 'plugsky') return true;if (platform === 'inferbase' || platform === 'simplellm') return true;if (['electronhub', 'experiential', 'router9', 'septor', 'clod', 'speechify', 'blaze', 'lucidity', 'airforce', 'dreamprompting', 'waterfall', 'logfare'].includes(platform)) return true;- return ['openrouter', 'google', 'groq', 'cerebras', 'sail', 'bai', 'radeon', 'sambanova', 'nvidia', 'mistral', 'github', 'cohere', 'cloudflare', 'zhipu', 'ollama', 'kilo', 'pollinations', 'llm7', 'huggingface', 'opencode', 'routeway', 'bazaarlink', 'ainative', 'aion', 'requesty', 'navy', 'nara', 'sealion', 'orcarouter', 'unorouter', 'xkiro', 'anyapi', 'modelscope', 'aihorde'].includes(platform);+ return ['openrouter', 'google', 'groq', 'cerebras', 'sail', 'bai', 'radeon', 'sambanova', 'nvidia', 'mistral', 'cohere', 'cloudflare', 'zhipu', 'ollama', 'kilo', 'pollinations', 'llm7', 'huggingface', 'opencode', 'routeway', 'bazaarlink', 'ainative', 'aion', 'requesty', 'navy', 'nara', 'sealion', 'orcarouter', 'unorouter', 'xkiro', 'anyapi', 'modelscope', 'aihorde'].includes(platform);}type HeaderSpec = { metric: QuotaMetric; limit: string; remaining?: string; reset?: string; strategy?: QuotaResetStrategy };diff --git a/server/src/services/router.ts b/server/src/services/router.tsindex e956b769..57581f9f 100644--- a/server/src/services/router.ts+++ b/server/src/services/router.ts@@ -1799,13 +1799,6 @@ function getModelChainRow(db: Db, modelDbId: number): ChainRow | undefined {*/export const CONTEXT_WINDOW_SAFETY_FACTOR = 1.25;-// Platforms whose pre-dispatch trim guard already caps the dispatched input-// below the live context ceiling (lib/content.ts truncateMessagesForGithub):-// the guard — not the routing estimate — is what guarantees the fit there, so-// applying the factor too would only make that guard unreachable. The margin-// checks below treat these platforms as strict comparisons.-const TRIM_GUARDED_PLATFORMS = new Set(['github']);-/** True when `estimatedTokens` fits the RAW advertised window (null window =* unknown, never filtered — same convention as the auto-router). This is the* comparison /v1/models publishes and the soft-preference fallback tier.@@ -1819,17 +1812,15 @@ export function fitsContextWindowStrict(contextWindow: number | null | undefined/** True when `estimatedTokens` plausibly fits `contextWindow` WITH the safety* margin. The chars/4 heuristic portion is scaled by the factor; an explicit* output reserve derived from the client's max_tokens (`routingReserveTokens`)- * is already an exact count and is added UNSCALED (#956 review). Trim-guarded- * platforms compare strictly — their guard guarantees the fit. Also enforces+ * is already an exact count and is added UNSCALED (#956 review). Also enforces* the operator's min-context-window floor (lib/min-context-window.ts): a model* below the configured preset is excluded from every chain, while an unknown* window (null) always passes. */-export function fitsContextWindow(platform: string, contextWindow: number | null | undefined, estimatedTokens: number, exactOutputReserve = 0): boolean {+export function fitsContextWindow(_platform: string, contextWindow: number | null | undefined, estimatedTokens: number, exactOutputReserve = 0): boolean {if (!passesContextWindowFloor(contextWindow)) return false;if (contextWindow == null) return true;// Raw advertised comparison first — the margin can only shrink eligibility.if (estimatedTokens > contextWindow) return false;- if (TRIM_GUARDED_PLATFORMS.has(platform)) return true;const reserve = Math.max(0, exactOutputReserve);const heuristic = Math.max(0, estimatedTokens - reserve);return heuristic * CONTEXT_WINDOW_SAFETY_FACTOR + reserve <= contextWindow;@@ -2302,9 +2293,7 @@ export function routeRequest(estimatedTokens = 1000, skipKeys?: Set<string>, pre// false (#956 review): e.g. `context 131072 < estimated 106000 x1.25 = 132500`.const reserve = Math.max(0, exactOutputReserve);const requiredWithMargin = Math.ceil(Math.max(0, estimatedTokens - reserve) * CONTEXT_WINDOW_SAFETY_FACTOR + reserve);- diag.push(TRIM_GUARDED_PLATFORMS.has(entry.platform)- ? `${label}: context ${entry.context_window} < estimated ${estimatedTokens}`- : `${label}: context ${entry.context_window} < estimated ${estimatedTokens} x${CONTEXT_WINDOW_SAFETY_FACTOR} = ${requiredWithMargin}`);+ diag.push(`${label}: context ${entry.context_window} < estimated ${estimatedTokens} x${CONTEXT_WINDOW_SAFETY_FACTOR} = ${requiredWithMargin}`);continue;}diff --git a/shared/types.ts b/shared/types.tsindex 89ebd228..f48fb04a 100644--- a/shared/types.ts+++ b/shared/types.ts@@ -126,7 +126,6 @@ export type Platform =| 'mistral'| 'sambanova'| 'openrouter'- | 'github'| 'cohere'// Web search APIs (#1174), not chat providers. Their keys serve POST// /v1/search (and the agents' web_search tools) through the catalog's