From 7395d71e1de79a747496a9dd3f403951a5107212 Mon Sep 17 00:00:00 2001 From: OmniRoute Ops Date: Mon, 11 May 2026 15:04:37 +0000 Subject: [PATCH 1/4] fix(registry): set kimi-coding defaultContextLength to 262144 (K2.6 native) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The Kimi Code OAuth product (https://api.kimi.com/coding/v1/messages) runs on the Kimi K2.6 backbone, which has a 262144 (256K) native context window per Moonshot's published platform docs. The KIMI_CODING_SHARED registry block had no defaultContextLength set, and the OAuth Coding plan is not covered by the models.dev sync (no rows in model_capabilities), so contextManager.ts:getTokenLimit fell through to DEFAULT_LIMITS.default = 128000 — half the actual model capacity. This propagates to /v1/models advertised context_length=128000 for kimi-coding/kimi-k2.6 and kmc/kimi-k2.6, which under-reports the prompt budget to downstream clients. Capy and similar clients that compute prompt_cap = context_length - request.max_tokens then end up with an artificially low cap (128K - 64K = 64K for Captain agent), causing premature plateau in long conversations. Reference: cross-provider model_capabilities rows in the DB confirm the 262144 value (openrouter/moonshotai/kimi-k2.6, moonshot/kimi-k2.6, ali/kimi-k2.6, deepinfra/moonshotai/Kimi-K2.6, hf/moonshotai/Kimi-K2.6, and ~30 others). 128000 was a per-provider-default underbid only because the OAuth Coding plan never gets a sync row. The model_capabilities DB rows for synced providers override this default, so any future syncing or per-model overrides still work as intended. Co-Authored-By: Claude Opus 4.7 (1M context) --- open-sse/config/providerRegistry.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/open-sse/config/providerRegistry.ts b/open-sse/config/providerRegistry.ts index d5982f751c..3d7b45f6e5 100644 --- a/open-sse/config/providerRegistry.ts +++ b/open-sse/config/providerRegistry.ts @@ -130,6 +130,15 @@ const KIMI_CODING_SHARED = { executor: "default", baseUrl: "https://api.kimi.com/coding/v1/messages", authHeader: "x-api-key", + // Kimi K2.6 native context per Moonshot platform docs and cross-provider + // catalog (openrouter, moonshot, ali, deepinfra, etc. all advertise 262144). + // Without this, contextManager.ts:getTokenLimit falls back to + // DEFAULT_LIMITS.default = 128000 because the Kimi Code OAuth product is + // not synced via models.dev. The under-reported value cascades into + // /v1/models advertised context_length=128000 and downstream client + // assumptions about prompt budget (e.g. Capy computing + // prompt_cap = context_length - request.max_tokens). + defaultContextLength: 262144, headers: { "Anthropic-Version": ANTHROPIC_VERSION_HEADER, }, From fa3b6d18ac0ffddfde4b05406c3dba785fc73d65 Mon Sep 17 00:00:00 2001 From: OmniRoute Ops Date: Mon, 11 May 2026 15:24:20 +0000 Subject: [PATCH 2/4] chore(registry): per-model contextLength/maxOutputTokens for active providers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The /v1/models catalog endpoint reads `model.contextLength` directly from the REGISTRY entries (src/app/api/v1/models/catalog.ts:823) and falls back to REGISTRY[provider].defaultContextLength → getTokenLimit chain otherwise. `max_output_tokens` flows through enrichCatalogModelEntry which calls getResolvedModelCapabilities (src/lib/modelCapabilities.ts:261-265) reading the same per-model registry fields. Currently most non-default-spec models lack explicit contextLength / maxOutputTokens, so /v1/models advertises stale defaults (DEFAULT_LIMITS.default = 128000, MODEL_SPECS.__default__.maxOutputTokens = 8192). Clients that read these values to compute compression thresholds or prompt budgets (e.g. Capy reading context_length for its compress trigger) over-aggressively trim long conversations. Provider IDs in the registry (`claude`, `kimi-coding`, `xiaomi-mimo`) do not match the canonical IDs synced from models.dev (`anthropic`, `cc`, `xiaomi`), so the DB lookup misses for these entries. The cleanest fix is to populate the registry directly with values consensus'd across 6+ upstream sync sources (anthropic, cc, openrouter, kilocode, vercel, xiaomi-token-plan-*, llmgateway, kc, kilo-gateway). Values: - claude (id="claude", alias="cc"): opus-4-7, opus-4-6 → 1M ctx / 128K max_out opus-4-5-20251101, sonnet-4-6, sonnet-4-5-20250929, haiku-4-5-20251001 → 200K ctx / 64K max_out - kiro (alias="kr"): same opus/sonnet/haiku tiering - github (alias="gh"): same claude subset tiering - KIMI_CODING_SHARED: kimi-k2.6, kimi-k2.6-thinking → 262K ctx / 262K max_out - xiaomi-mimo: mimo-v2.5-pro, mimo-v2.5 → 1M ctx / 131K max_out mimo-v2-omni → 262K ctx / 131K max_out mimo-v2-flash → 262K ctx / 65K max_out The 1M context tier for claude-opus-4-6/4-7 requires the `context-1m-2025-08-07` beta header which selectBetaFlags() already attaches automatically for full-agent traffic (hasTools && hasSystem, the Capy pattern) — see open-sse/executors/claudeIdentity.ts:304. No wire-level change needed. Co-Authored-By: Claude Opus 4.7 (1M context) --- open-sse/config/providerRegistry.ts | 48 +++++++++++++++-------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/open-sse/config/providerRegistry.ts b/open-sse/config/providerRegistry.ts index 3d7b45f6e5..8b6bb51cef 100644 --- a/open-sse/config/providerRegistry.ts +++ b/open-sse/config/providerRegistry.ts @@ -143,8 +143,8 @@ const KIMI_CODING_SHARED = { "Anthropic-Version": ANTHROPIC_VERSION_HEADER, }, models: [ - { id: "kimi-k2.6", name: "Kimi K2.6" }, - { id: "kimi-k2.6-thinking", name: "Kimi K2.6 Thinking" }, + { id: "kimi-k2.6", name: "Kimi K2.6", contextLength: 262144, maxOutputTokens: 262144 }, + { id: "kimi-k2.6-thinking", name: "Kimi K2.6 Thinking", contextLength: 262144, maxOutputTokens: 262144 }, ] as RegistryModel[], } as const; @@ -281,7 +281,12 @@ const CHAT_OPENAI_COMPAT_MODELS: Record = { codestral: buildModels(["codestral-2405", "codestral-latest"]), upstage: buildModels(["solar-pro3", "solar-mini"]), maritalk: buildModels(["sabia-4", "sabia-3.1", "sabiazinho-4", "sabiazinho-3"]), - "xiaomi-mimo": buildModels(["mimo-v2.5-pro", "mimo-v2.5", "mimo-v2-omni", "mimo-v2-flash"]), + "xiaomi-mimo": [ + { id: "mimo-v2.5-pro", name: "MiMo-V2.5-Pro", contextLength: 1048576, maxOutputTokens: 131072 }, + { id: "mimo-v2.5", name: "MiMo-V2.5", contextLength: 1048576, maxOutputTokens: 131072 }, + { id: "mimo-v2-omni", name: "MiMo-V2-Omni", contextLength: 262144, maxOutputTokens: 131072 }, + { id: "mimo-v2-flash", name: "MiMo-V2-Flash", contextLength: 262144, maxOutputTokens: 65536 }, + ], "inference-net": buildModels([ "meta-llama/Llama-3.3-70B-Instruct", "deepseek-ai/DeepSeek-R1", @@ -379,11 +384,12 @@ export const REGISTRY: Record = { tokenUrl: "https://console.anthropic.com/v1/oauth/token", }, models: [ - { id: "claude-opus-4-7", name: "Claude Opus 4.7", supportsXHighEffort: true }, - { id: "claude-opus-4-6", name: "Claude Opus 4.6", supportsXHighEffort: false }, - { id: "claude-sonnet-4-6", name: "Claude 4.6 Sonnet", supportsXHighEffort: false }, - { id: "claude-sonnet-4-5-20250929", name: "Claude 4.5 Sonnet", supportsXHighEffort: false }, - { id: "claude-haiku-4-5-20251001", name: "Claude 4.5 Haiku", supportsXHighEffort: false }, + { id: "claude-opus-4-7", name: "Claude Opus 4.7", supportsXHighEffort: true, contextLength: 1000000, maxOutputTokens: 128000 }, + { id: "claude-opus-4-6", name: "Claude Opus 4.6", supportsXHighEffort: false, contextLength: 1000000, maxOutputTokens: 128000 }, + { id: "claude-opus-4-5-20251101", name: "Claude Opus 4.5", supportsXHighEffort: false, contextLength: 200000, maxOutputTokens: 64000 }, + { id: "claude-sonnet-4-6", name: "Claude 4.6 Sonnet", supportsXHighEffort: false, contextLength: 200000, maxOutputTokens: 64000 }, + { id: "claude-sonnet-4-5-20250929", name: "Claude 4.5 Sonnet", supportsXHighEffort: false, contextLength: 200000, maxOutputTokens: 64000 }, + { id: "claude-haiku-4-5-20251001", name: "Claude 4.5 Haiku", supportsXHighEffort: false, contextLength: 200000, maxOutputTokens: 64000 }, ], }, @@ -567,16 +573,12 @@ export const REGISTRY: Record = { { id: "gpt-5.4-mini", name: "GPT-5.4 Mini", targetFormat: "openai-responses" }, { id: "gpt-5.4", name: "GPT-5.4", targetFormat: "openai-responses" }, { id: "gpt-5.5", name: "GPT-5.5", ...GPT_5_5_CODEX_CAPABILITIES }, - { id: "claude-haiku-4.5", name: "Claude Haiku 4.5", targetFormat: "openai-responses" }, - { id: "claude-sonnet-4.5", name: "Claude Sonnet 4.5", targetFormat: "openai-responses" }, - { id: "claude-sonnet-4.6", name: "Claude Sonnet 4.6", targetFormat: "openai-responses" }, - { - id: "claude-opus-4-5-20251101", - name: "Claude Opus 4.5 (Full ID)", - targetFormat: "openai-responses", - }, - { id: "claude-opus-4.6", name: "Claude Opus 4.6", targetFormat: "openai-responses" }, - { id: "claude-opus-4.7", name: "Claude Opus 4.7", targetFormat: "openai-responses" }, + { id: "claude-haiku-4.5", name: "Claude Haiku 4.5", targetFormat: "openai-responses", contextLength: 200000, maxOutputTokens: 64000 }, + { id: "claude-sonnet-4.5", name: "Claude Sonnet 4.5", targetFormat: "openai-responses", contextLength: 200000, maxOutputTokens: 64000 }, + { id: "claude-sonnet-4.6", name: "Claude Sonnet 4.6", targetFormat: "openai-responses", contextLength: 200000, maxOutputTokens: 64000 }, + { id: "claude-opus-4-5-20251101", name: "Claude Opus 4.5 (Full ID)", targetFormat: "openai-responses", contextLength: 200000, maxOutputTokens: 64000 }, + { id: "claude-opus-4.6", name: "Claude Opus 4.6", targetFormat: "openai-responses", contextLength: 1000000, maxOutputTokens: 128000 }, + { id: "claude-opus-4.7", name: "Claude Opus 4.7", targetFormat: "openai-responses", contextLength: 1000000, maxOutputTokens: 128000 }, { id: "gemini-3.1-pro-preview", name: "Gemini 3.1 Pro", targetFormat: "openai-responses" }, { id: "gemini-3-flash-preview", name: "Gemini 3 Flash", targetFormat: "openai-responses" }, { id: "oswe-vscode-prime", name: "Raptor Mini", targetFormat: "openai-responses" }, @@ -600,12 +602,12 @@ export const REGISTRY: Record = { }, models: [ { id: "auto-kiro", name: "Auto (Kiro picks best model)" }, - { id: "claude-opus-4.7", name: "Claude Opus 4.7" }, - { id: "claude-opus-4.6", name: "Claude Opus 4.6" }, - { id: "claude-sonnet-4.6", name: "Claude Sonnet 4.6" }, + { id: "claude-opus-4.7", name: "Claude Opus 4.7", contextLength: 1000000, maxOutputTokens: 128000 }, + { id: "claude-opus-4.6", name: "Claude Opus 4.6", contextLength: 1000000, maxOutputTokens: 128000 }, + { id: "claude-sonnet-4.6", name: "Claude Sonnet 4.6", contextLength: 200000, maxOutputTokens: 64000 }, // models for kiro free tier - { id: "claude-sonnet-4.5", name: "Claude Sonnet 4.5" }, - { id: "claude-haiku-4.5", name: "Claude Haiku 4.5" }, + { id: "claude-sonnet-4.5", name: "Claude Sonnet 4.5", contextLength: 200000, maxOutputTokens: 64000 }, + { id: "claude-haiku-4.5", name: "Claude Haiku 4.5", contextLength: 200000, maxOutputTokens: 64000 }, { id: "deepseek-3.2", name: "DeepSeek V3.2" }, { id: "minimax-m2.5", name: "MiniMax M2.5" }, { id: "minimax-m2.1", name: "MiniMax M2.1" }, From ef1022e9c8946d36dfa13365fbaedba6c8fa0324 Mon Sep 17 00:00:00 2001 From: OmniRoute Ops Date: Mon, 11 May 2026 15:34:05 +0000 Subject: [PATCH 3/4] fix(registry): cap gpt-5.5 codex OAuth contextLength at 400K (not 1.05M) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The codex OAuth backend (chatgpt.com/backend-api/codex/responses) caps the gpt-5.5 context window at 400 000 tokens, not the 1 050 000 advertised by the public OpenAI API. Clients reading /v1/models for prompt-budget math (e.g. Capy computing compression thresholds) would otherwise allow prompts beyond the OAuth backend's actual capacity, triggering silent truncation or upstream 400s. Per-entry override of GPT_5_5_CODEX_CAPABILITIES (which spreads contextLength=1050000 from the shared constant) — the constant itself is unchanged because it's also consumed by the github provider's gpt-5.5 entry where DB sync provides the canonical 400K/128K values. max_output_tokens=128000 is informational only — the codex OAuth backend strips max_output_tokens server-side (LiteLLM and Codex CLI both confirm this). Advertising a realistic value still helps clients that read it for token-budget heuristics. References : - openai/codex#19208 "1M context window gone after GPT-5.5 release" - openai/codex#19319 — 258 400 effective context window observation - openai/codex#19464 — Support 1M for GPT-5.5 in Codex (feature ask) - opencode#24171 — GPT-5.5 Codex 400K vs API 1M - BerriAI/litellm#21193 — codex backend rejects unsupported params - openai/codex#4138 — model_max_output_tokens not wired up Co-Authored-By: Claude Opus 4.7 (1M context) --- open-sse/config/providerRegistry.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/open-sse/config/providerRegistry.ts b/open-sse/config/providerRegistry.ts index 8b6bb51cef..8d55e95c57 100644 --- a/open-sse/config/providerRegistry.ts +++ b/open-sse/config/providerRegistry.ts @@ -462,11 +462,15 @@ export const REGISTRY: Record = { tokenUrl: "https://auth.openai.com/oauth/token", }, models: [ - { id: "gpt-5.5", name: "GPT 5.5", ...GPT_5_5_CODEX_CAPABILITIES }, - { id: "gpt-5.5-xhigh", name: "GPT 5.5 (xHigh)", ...GPT_5_5_CODEX_CAPABILITIES }, - { id: "gpt-5.5-high", name: "GPT 5.5 (High)", ...GPT_5_5_CODEX_CAPABILITIES }, - { id: "gpt-5.5-medium", name: "GPT 5.5 (Medium)", ...GPT_5_5_CODEX_CAPABILITIES }, - { id: "gpt-5.5-low", name: "GPT 5.5 (Low)", ...GPT_5_5_CODEX_CAPABILITIES }, + // gpt-5.5 codex OAuth backend caps context at 400K (not the public-API + // 1.05M). Public refs : openai/codex#19208, #19319, #19464 ; + // opencode#24171. max_output_tokens is stripped server-side + // (litellm#21193, codex#4138) so 128K is informational only. + { id: "gpt-5.5", name: "GPT 5.5", ...GPT_5_5_CODEX_CAPABILITIES, contextLength: 400000, maxOutputTokens: 128000 }, + { id: "gpt-5.5-xhigh", name: "GPT 5.5 (xHigh)", ...GPT_5_5_CODEX_CAPABILITIES, contextLength: 400000, maxOutputTokens: 128000 }, + { id: "gpt-5.5-high", name: "GPT 5.5 (High)", ...GPT_5_5_CODEX_CAPABILITIES, contextLength: 400000, maxOutputTokens: 128000 }, + { id: "gpt-5.5-medium", name: "GPT 5.5 (Medium)", ...GPT_5_5_CODEX_CAPABILITIES, contextLength: 400000, maxOutputTokens: 128000 }, + { id: "gpt-5.5-low", name: "GPT 5.5 (Low)", ...GPT_5_5_CODEX_CAPABILITIES, contextLength: 400000, maxOutputTokens: 128000 }, { id: "gpt-5.4", name: "GPT 5.4", targetFormat: "openai-responses" }, { id: "gpt-5.4-mini", name: "GPT 5.4 Mini", targetFormat: "openai-responses" }, { id: "gpt-5.3-codex-spark", name: "GPT 5.3 Codex Spark" }, From 992848431b38ea7eb4b01ffd121974d930759cde Mon Sep 17 00:00:00 2001 From: OmniRoute Ops Date: Mon, 11 May 2026 16:25:00 +0000 Subject: [PATCH 4/4] address review: add MODEL_SPECS entries for new claude/kimi/mimo models Per gemini-code-assist review on #2163, the registry contextLength/ maxOutputTokens values were being silently capped to 8192 by capMaxOutputTokens() because the model IDs were absent from MODEL_SPECS, falling back to __default__.maxOutputTokens. Adds entries with matching limits : - claude-opus-4-5-20251101 : 64000 max_out (overrides prefix-match to claude-opus-4-5 which has 32768) - claude-opus-4-6 : 128000 max_out, 1M context tier - claude-sonnet-4-6, claude-sonnet-4-5-20250929, claude-haiku-4-5-20251001 : 64000 max_out each - kimi-k2.6 : 262144 max_out, 262144 context, with aliases for kimi-k2.6-thinking and kimi-for-coding - mimo-v2.5-pro / mimo-v2.5 : 131072 max_out, 1048576 context - mimo-v2-omni : 131072 max_out, 262144 context - mimo-v2-flash : 65536 max_out, 262144 context Each entry carries `aliases` where dot-notation variants exist (e.g. claude-opus-4.6), so capMaxOutputTokens resolves them via the explicit alias lookup before falling back to the prefix-match path. --- src/shared/constants/modelSpecs.ts | 82 ++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/src/shared/constants/modelSpecs.ts b/src/shared/constants/modelSpecs.ts index 079b6e04b7..64de28c63a 100644 --- a/src/shared/constants/modelSpecs.ts +++ b/src/shared/constants/modelSpecs.ts @@ -79,6 +79,27 @@ export const MODEL_SPECS: Record = { supportsVision: true, }, + // ── Claude Opus 4.5 (full ID — overrides prefix match on claude-opus-4-5) ── + "claude-opus-4-5-20251101": { + maxOutputTokens: 64000, + contextWindow: 200000, + defaultThinkingBudget: 10000, + thinkingBudgetCap: 32000, + supportsThinking: true, + supportsTools: true, + supportsVision: true, + }, + + // ── Claude Opus 4.6 (1M context tier) ─────────────────────────── + "claude-opus-4-6": { + maxOutputTokens: 128000, + contextWindow: 1000000, + supportsThinking: true, + supportsTools: true, + supportsVision: true, + aliases: ["claude-opus-4.6"], + }, + // ── Claude Opus 4.7 ───────────────────────────────────────────── "claude-opus-4-7": { maxOutputTokens: 128000, @@ -89,6 +110,67 @@ export const MODEL_SPECS: Record = { aliases: ["claude-opus-4.7"], }, + // ── Claude Sonnet 4.6 ─────────────────────────────────────────── + "claude-sonnet-4-6": { + maxOutputTokens: 64000, + contextWindow: 200000, + supportsThinking: true, + supportsTools: true, + supportsVision: true, + aliases: ["claude-sonnet-4.6"], + }, + + // ── Claude Sonnet 4.5 ─────────────────────────────────────────── + "claude-sonnet-4-5-20250929": { + maxOutputTokens: 64000, + contextWindow: 200000, + supportsThinking: true, + supportsTools: true, + supportsVision: true, + aliases: ["claude-sonnet-4.5"], + }, + + // ── Claude Haiku 4.5 ──────────────────────────────────────────── + "claude-haiku-4-5-20251001": { + maxOutputTokens: 64000, + contextWindow: 200000, + supportsThinking: true, + supportsTools: true, + supportsVision: true, + aliases: ["claude-haiku-4.5"], + }, + + // ── Kimi K2.6 (Moonshot Kimi Code OAuth — 262K native) ────────── + "kimi-k2.6": { + maxOutputTokens: 262144, + contextWindow: 262144, + supportsThinking: true, + supportsTools: true, + aliases: ["kimi-k2.6-thinking", "kimi-for-coding"], + }, + + // ── Xiaomi MiMo V2.5 (1M context, consensus across 7+ sync sources) ── + "mimo-v2.5-pro": { + maxOutputTokens: 131072, + contextWindow: 1048576, + supportsTools: true, + }, + "mimo-v2.5": { + maxOutputTokens: 131072, + contextWindow: 1048576, + supportsTools: true, + }, + "mimo-v2-omni": { + maxOutputTokens: 131072, + contextWindow: 262144, + supportsTools: true, + }, + "mimo-v2-flash": { + maxOutputTokens: 65536, + contextWindow: 262144, + supportsTools: true, + }, + // Defaults __default__: { maxOutputTokens: 8192,