From 841011d96fcce12c877fd139d2187d6699fd05ca Mon Sep 17 00:00:00 2001 From: Roo Code Date: Tue, 24 Feb 2026 02:08:59 +0000 Subject: [PATCH 1/3] feat: add OpenRouter quantization filter to exclude low-bit providers Adds an opt-in checkbox to filter out low-bit quantization providers (FP4/FP6/Int4) when using OpenRouter, preventing broken CJK encoding. - Add openRouterExcludeLowQuantization to provider settings schema - Add buildProviderOptions() method to centralize provider options - Add UI checkbox in OpenRouter settings - Add i18n translations for all 18 locales - Add 6 tests for buildProviderOptions behavior Closes #11325 --- packages/types/src/provider-settings.ts | 1 + .../providers/__tests__/openrouter.spec.ts | 73 +++++++++++++++++++ src/api/providers/openrouter.ts | 61 +++++++++++----- .../settings/providers/OpenRouter.tsx | 12 +++ webview-ui/src/i18n/locales/ca/settings.json | 4 + webview-ui/src/i18n/locales/de/settings.json | 4 + webview-ui/src/i18n/locales/en/settings.json | 4 + webview-ui/src/i18n/locales/es/settings.json | 4 + webview-ui/src/i18n/locales/fr/settings.json | 4 + webview-ui/src/i18n/locales/hi/settings.json | 4 + webview-ui/src/i18n/locales/id/settings.json | 4 + webview-ui/src/i18n/locales/it/settings.json | 4 + webview-ui/src/i18n/locales/ja/settings.json | 4 + webview-ui/src/i18n/locales/ko/settings.json | 4 + webview-ui/src/i18n/locales/nl/settings.json | 4 + webview-ui/src/i18n/locales/pl/settings.json | 4 + .../src/i18n/locales/pt-BR/settings.json | 4 + webview-ui/src/i18n/locales/ru/settings.json | 4 + webview-ui/src/i18n/locales/tr/settings.json | 4 + webview-ui/src/i18n/locales/vi/settings.json | 4 + .../src/i18n/locales/zh-CN/settings.json | 4 + .../src/i18n/locales/zh-TW/settings.json | 4 + 22 files changed, 201 insertions(+), 18 deletions(-) diff --git a/packages/types/src/provider-settings.ts b/packages/types/src/provider-settings.ts index 859792d7c36..c38b4e75be1 100644 --- a/packages/types/src/provider-settings.ts +++ b/packages/types/src/provider-settings.ts @@ -206,6 +206,7 @@ const openRouterSchema = baseProviderSettingsSchema.extend({ openRouterModelId: z.string().optional(), openRouterBaseUrl: z.string().optional(), openRouterSpecificProvider: z.string().optional(), + openRouterExcludeLowQuantization: z.boolean().optional(), }) const bedrockSchema = apiModelIdProviderModelSchema.extend({ diff --git a/src/api/providers/__tests__/openrouter.spec.ts b/src/api/providers/__tests__/openrouter.spec.ts index e03abea6352..6797ca588be 100644 --- a/src/api/providers/__tests__/openrouter.spec.ts +++ b/src/api/providers/__tests__/openrouter.spec.ts @@ -698,4 +698,77 @@ describe("OpenRouterHandler", () => { ) }) }) + + describe("buildProviderOptions", () => { + it("returns undefined when no specific provider and no quantization filter", () => { + const handler = new OpenRouterHandler({ + openRouterApiKey: "test-key", + openRouterModelId: "anthropic/claude-sonnet-4", + }) + const result = (handler as any).buildProviderOptions() + expect(result).toBeUndefined() + }) + + it("returns provider routing when specific provider is set", () => { + const handler = new OpenRouterHandler({ + openRouterApiKey: "test-key", + openRouterModelId: "anthropic/claude-sonnet-4", + openRouterSpecificProvider: "Anthropic", + }) + const result = (handler as any).buildProviderOptions() + expect(result).toEqual({ + order: ["Anthropic"], + only: ["Anthropic"], + allow_fallbacks: false, + }) + }) + + it("returns quantizations when excludeLowQuantization is enabled", () => { + const handler = new OpenRouterHandler({ + openRouterApiKey: "test-key", + openRouterModelId: "anthropic/claude-sonnet-4", + openRouterExcludeLowQuantization: true, + }) + const result = (handler as any).buildProviderOptions() + expect(result).toEqual({ + quantizations: ["fp16", "bf16", "fp8", "int8"], + }) + }) + + it("combines specific provider and quantization filter", () => { + const handler = new OpenRouterHandler({ + openRouterApiKey: "test-key", + openRouterModelId: "anthropic/claude-sonnet-4", + openRouterSpecificProvider: "Anthropic", + openRouterExcludeLowQuantization: true, + }) + const result = (handler as any).buildProviderOptions() + expect(result).toEqual({ + order: ["Anthropic"], + only: ["Anthropic"], + allow_fallbacks: false, + quantizations: ["fp16", "bf16", "fp8", "int8"], + }) + }) + + it("returns undefined when specific provider is the default", () => { + const handler = new OpenRouterHandler({ + openRouterApiKey: "test-key", + openRouterModelId: "anthropic/claude-sonnet-4", + openRouterSpecificProvider: "[default]", + }) + const result = (handler as any).buildProviderOptions() + expect(result).toBeUndefined() + }) + + it("returns undefined when excludeLowQuantization is false", () => { + const handler = new OpenRouterHandler({ + openRouterApiKey: "test-key", + openRouterModelId: "anthropic/claude-sonnet-4", + openRouterExcludeLowQuantization: false, + }) + const result = (handler as any).buildProviderOptions() + expect(result).toBeUndefined() + }) + }) }) diff --git a/src/api/providers/openrouter.ts b/src/api/providers/openrouter.ts index 7fcc24b15f6..cab2b5b7aa2 100644 --- a/src/api/providers/openrouter.ts +++ b/src/api/providers/openrouter.ts @@ -317,15 +317,7 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH messages: openAiMessages, stream: true, stream_options: { include_usage: true }, - // Only include provider if openRouterSpecificProvider is not "[default]". - ...(this.options.openRouterSpecificProvider && - this.options.openRouterSpecificProvider !== OPENROUTER_DEFAULT_PROVIDER_NAME && { - provider: { - order: [this.options.openRouterSpecificProvider], - only: [this.options.openRouterSpecificProvider], - allow_fallbacks: false, - }, - }), + ...(this.buildProviderOptions() && { provider: this.buildProviderOptions() }), ...(reasoning && { reasoning }), tools: this.convertToolsForOpenAI(metadata?.tools), tool_choice: metadata?.tool_choice, @@ -574,6 +566,47 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH return { id, info, topP: isDeepSeekR1 ? 0.95 : undefined, ...params } } + /** + * Build the `provider` options object for OpenRouter requests. + * Combines specific provider routing and quantization filtering. + */ + private buildProviderOptions(): + | { + order?: string[] + only?: string[] + allow_fallbacks?: boolean + quantizations?: string[] + } + | undefined { + const hasSpecificProvider = + this.options.openRouterSpecificProvider && + this.options.openRouterSpecificProvider !== OPENROUTER_DEFAULT_PROVIDER_NAME + const excludeLowQuantization = this.options.openRouterExcludeLowQuantization + + if (!hasSpecificProvider && !excludeLowQuantization) { + return undefined + } + + const provider: { + order?: string[] + only?: string[] + allow_fallbacks?: boolean + quantizations?: string[] + } = {} + + if (hasSpecificProvider) { + provider.order = [this.options.openRouterSpecificProvider!] + provider.only = [this.options.openRouterSpecificProvider!] + provider.allow_fallbacks = false + } + + if (excludeLowQuantization) { + provider.quantizations = ["fp16", "bf16", "fp8", "int8"] + } + + return provider + } + async completePrompt(prompt: string) { let { id: modelId, maxTokens, temperature, reasoning } = await this.fetchModel() @@ -583,15 +616,7 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH temperature, messages: [{ role: "user", content: prompt }], stream: false, - // Only include provider if openRouterSpecificProvider is not "[default]". - ...(this.options.openRouterSpecificProvider && - this.options.openRouterSpecificProvider !== OPENROUTER_DEFAULT_PROVIDER_NAME && { - provider: { - order: [this.options.openRouterSpecificProvider], - only: [this.options.openRouterSpecificProvider], - allow_fallbacks: false, - }, - }), + ...(this.buildProviderOptions() && { provider: this.buildProviderOptions() }), ...(reasoning && { reasoning }), } diff --git a/webview-ui/src/components/settings/providers/OpenRouter.tsx b/webview-ui/src/components/settings/providers/OpenRouter.tsx index 2dba8c8459f..8ada9cc6bb4 100644 --- a/webview-ui/src/components/settings/providers/OpenRouter.tsx +++ b/webview-ui/src/components/settings/providers/OpenRouter.tsx @@ -103,6 +103,18 @@ export const OpenRouter = ({ )} )} +
+ { + setApiConfigurationField("openRouterExcludeLowQuantization", checked) + }}> + {t("settings:providers.openRouter.excludeLowQuantization.label")} + +
+ {t("settings:providers.openRouter.excludeLowQuantization.description")} +
+
Date: Tue, 24 Feb 2026 02:50:11 +0000 Subject: [PATCH 2/3] fix: translate excludeLowQuantization keys into proper native languages for all locales --- webview-ui/src/i18n/locales/ca/settings.json | 4 ++-- webview-ui/src/i18n/locales/de/settings.json | 4 ++-- webview-ui/src/i18n/locales/es/settings.json | 4 ++-- webview-ui/src/i18n/locales/fr/settings.json | 4 ++-- webview-ui/src/i18n/locales/hi/settings.json | 4 ++-- webview-ui/src/i18n/locales/id/settings.json | 4 ++-- webview-ui/src/i18n/locales/it/settings.json | 4 ++-- webview-ui/src/i18n/locales/ja/settings.json | 4 ++-- webview-ui/src/i18n/locales/ko/settings.json | 4 ++-- webview-ui/src/i18n/locales/nl/settings.json | 4 ++-- webview-ui/src/i18n/locales/pl/settings.json | 4 ++-- webview-ui/src/i18n/locales/pt-BR/settings.json | 4 ++-- webview-ui/src/i18n/locales/ru/settings.json | 4 ++-- webview-ui/src/i18n/locales/tr/settings.json | 4 ++-- webview-ui/src/i18n/locales/vi/settings.json | 4 ++-- webview-ui/src/i18n/locales/zh-CN/settings.json | 4 ++-- webview-ui/src/i18n/locales/zh-TW/settings.json | 4 ++-- 17 files changed, 34 insertions(+), 34 deletions(-) diff --git a/webview-ui/src/i18n/locales/ca/settings.json b/webview-ui/src/i18n/locales/ca/settings.json index eae76e610ce..5030e1328b7 100644 --- a/webview-ui/src/i18n/locales/ca/settings.json +++ b/webview-ui/src/i18n/locales/ca/settings.json @@ -479,8 +479,8 @@ "learnMore": "Més informació sobre l'encaminament de proveïdors" }, "excludeLowQuantization": { - "label": "Exclude low-bit quantization (FP4/FP6/Int4)", - "description": "Only allow higher precision providers (FP8/FP16/BF16/Int8). Helps prevent broken CJK (Korean/Chinese/Japanese) encoding from aggressively quantized models." + "label": "Excloure la quantització de baixa precisió (FP4/FP6/Int4)", + "description": "Permet només proveïdors d'alta precisió (FP8/FP16/BF16/Int8). Ajuda a prevenir problemes de codificació CJK (coreà/xinès/japonès) amb models agressivament quantitzats." } }, "customModel": { diff --git a/webview-ui/src/i18n/locales/de/settings.json b/webview-ui/src/i18n/locales/de/settings.json index bf2cd2861ab..3cfdf2f62ae 100644 --- a/webview-ui/src/i18n/locales/de/settings.json +++ b/webview-ui/src/i18n/locales/de/settings.json @@ -479,8 +479,8 @@ "learnMore": "Mehr über Anbieter-Routing erfahren" }, "excludeLowQuantization": { - "label": "Exclude low-bit quantization (FP4/FP6/Int4)", - "description": "Only allow higher precision providers (FP8/FP16/BF16/Int8). Helps prevent broken CJK (Korean/Chinese/Japanese) encoding from aggressively quantized models." + "label": "Niedrigbit-Quantisierung ausschließen (FP4/FP6/Int4)", + "description": "Nur Anbieter mit höherer Präzision erlauben (FP8/FP16/BF16/Int8). Hilft, fehlerhafte CJK-Kodierung (Koreanisch/Chinesisch/Japanisch) durch aggressiv quantisierte Modelle zu vermeiden." } }, "customModel": { diff --git a/webview-ui/src/i18n/locales/es/settings.json b/webview-ui/src/i18n/locales/es/settings.json index 9da257fb425..4dfbe6a78ce 100644 --- a/webview-ui/src/i18n/locales/es/settings.json +++ b/webview-ui/src/i18n/locales/es/settings.json @@ -479,8 +479,8 @@ "learnMore": "Más información sobre el enrutamiento de proveedores" }, "excludeLowQuantization": { - "label": "Exclude low-bit quantization (FP4/FP6/Int4)", - "description": "Only allow higher precision providers (FP8/FP16/BF16/Int8). Helps prevent broken CJK (Korean/Chinese/Japanese) encoding from aggressively quantized models." + "label": "Excluir cuantización de baja precisión (FP4/FP6/Int4)", + "description": "Solo permitir proveedores de mayor precisión (FP8/FP16/BF16/Int8). Ayuda a prevenir problemas de codificación CJK (coreano/chino/japonés) con modelos agresivamente cuantizados." } }, "customModel": { diff --git a/webview-ui/src/i18n/locales/fr/settings.json b/webview-ui/src/i18n/locales/fr/settings.json index 00f572f4e14..e3798b6197f 100644 --- a/webview-ui/src/i18n/locales/fr/settings.json +++ b/webview-ui/src/i18n/locales/fr/settings.json @@ -479,8 +479,8 @@ "learnMore": "En savoir plus sur le routage des fournisseurs" }, "excludeLowQuantization": { - "label": "Exclude low-bit quantization (FP4/FP6/Int4)", - "description": "Only allow higher precision providers (FP8/FP16/BF16/Int8). Helps prevent broken CJK (Korean/Chinese/Japanese) encoding from aggressively quantized models." + "label": "Exclure la quantification basse précision (FP4/FP6/Int4)", + "description": "N'autoriser que les fournisseurs de haute précision (FP8/FP16/BF16/Int8). Aide à prévenir les problèmes d'encodage CJK (coréen/chinois/japonais) avec les modèles agressivement quantifiés." } }, "customModel": { diff --git a/webview-ui/src/i18n/locales/hi/settings.json b/webview-ui/src/i18n/locales/hi/settings.json index 686bcccc4d6..f494d3e8ac3 100644 --- a/webview-ui/src/i18n/locales/hi/settings.json +++ b/webview-ui/src/i18n/locales/hi/settings.json @@ -479,8 +479,8 @@ "learnMore": "प्रदाता रूटिंग के बारे में अधिक जानें" }, "excludeLowQuantization": { - "label": "Exclude low-bit quantization (FP4/FP6/Int4)", - "description": "Only allow higher precision providers (FP8/FP16/BF16/Int8). Helps prevent broken CJK (Korean/Chinese/Japanese) encoding from aggressively quantized models." + "label": "कम-बिट क्वांटाइज़ेशन बाहर करें (FP4/FP6/Int4)", + "description": "केवल उच्च परिशुद्धता प्रदाताओं को अनुमति दें (FP8/FP16/BF16/Int8)। आक्रामक रूप से क्वांटाइज़ किए गए मॉडलों से टूटी हुई CJK (कोरियाई/चीनी/जापानी) एन्कोडिंग को रोकने में मदद करता है।" } }, "customModel": { diff --git a/webview-ui/src/i18n/locales/id/settings.json b/webview-ui/src/i18n/locales/id/settings.json index fc8b483e619..34ed0b4cb3c 100644 --- a/webview-ui/src/i18n/locales/id/settings.json +++ b/webview-ui/src/i18n/locales/id/settings.json @@ -479,8 +479,8 @@ "learnMore": "Pelajari lebih lanjut tentang provider routing" }, "excludeLowQuantization": { - "label": "Exclude low-bit quantization (FP4/FP6/Int4)", - "description": "Only allow higher precision providers (FP8/FP16/BF16/Int8). Helps prevent broken CJK (Korean/Chinese/Japanese) encoding from aggressively quantized models." + "label": "Kecualikan kuantisasi bit rendah (FP4/FP6/Int4)", + "description": "Hanya izinkan penyedia presisi tinggi (FP8/FP16/BF16/Int8). Membantu mencegah masalah encoding CJK (Korea/Cina/Jepang) dari model yang dikuantisasi secara agresif." } }, "customModel": { diff --git a/webview-ui/src/i18n/locales/it/settings.json b/webview-ui/src/i18n/locales/it/settings.json index 8231069d14c..372124c9b24 100644 --- a/webview-ui/src/i18n/locales/it/settings.json +++ b/webview-ui/src/i18n/locales/it/settings.json @@ -479,8 +479,8 @@ "learnMore": "Scopri di più sul routing dei fornitori" }, "excludeLowQuantization": { - "label": "Exclude low-bit quantization (FP4/FP6/Int4)", - "description": "Only allow higher precision providers (FP8/FP16/BF16/Int8). Helps prevent broken CJK (Korean/Chinese/Japanese) encoding from aggressively quantized models." + "label": "Escludi quantizzazione a bassa precisione (FP4/FP6/Int4)", + "description": "Consenti solo fornitori ad alta precisione (FP8/FP16/BF16/Int8). Aiuta a prevenire problemi di codifica CJK (coreano/cinese/giapponese) con modelli quantizzati aggressivamente." } }, "customModel": { diff --git a/webview-ui/src/i18n/locales/ja/settings.json b/webview-ui/src/i18n/locales/ja/settings.json index 17a1b5b26a3..686cfabc60b 100644 --- a/webview-ui/src/i18n/locales/ja/settings.json +++ b/webview-ui/src/i18n/locales/ja/settings.json @@ -479,8 +479,8 @@ "learnMore": "プロバイダールーティングについて詳しく知る" }, "excludeLowQuantization": { - "label": "Exclude low-bit quantization (FP4/FP6/Int4)", - "description": "Only allow higher precision providers (FP8/FP16/BF16/Int8). Helps prevent broken CJK (Korean/Chinese/Japanese) encoding from aggressively quantized models." + "label": "低ビット量子化を除外する (FP4/FP6/Int4)", + "description": "高精度プロバイダーのみを許可します (FP8/FP16/BF16/Int8)。積極的に量子化されたモデルによるCJK(韓国語/中国語/日本語)エンコーディングの問題を防ぎます。" } }, "customModel": { diff --git a/webview-ui/src/i18n/locales/ko/settings.json b/webview-ui/src/i18n/locales/ko/settings.json index 82dc61286d2..1f04d4950e1 100644 --- a/webview-ui/src/i18n/locales/ko/settings.json +++ b/webview-ui/src/i18n/locales/ko/settings.json @@ -479,8 +479,8 @@ "learnMore": "제공자 라우팅에 대해 자세히 알아보기" }, "excludeLowQuantization": { - "label": "Exclude low-bit quantization (FP4/FP6/Int4)", - "description": "Only allow higher precision providers (FP8/FP16/BF16/Int8). Helps prevent broken CJK (Korean/Chinese/Japanese) encoding from aggressively quantized models." + "label": "저비트 양자화 제외 (FP4/FP6/Int4)", + "description": "고정밀 제공자만 허용합니다 (FP8/FP16/BF16/Int8). 과도하게 양자화된 모델로 인한 CJK (한국어/중국어/일본어) 인코딩 오류를 방지하는 데 도움이 됩니다." } }, "customModel": { diff --git a/webview-ui/src/i18n/locales/nl/settings.json b/webview-ui/src/i18n/locales/nl/settings.json index 4947d1cfa16..c8b9542bf17 100644 --- a/webview-ui/src/i18n/locales/nl/settings.json +++ b/webview-ui/src/i18n/locales/nl/settings.json @@ -479,8 +479,8 @@ "learnMore": "Meer informatie over providerroutering" }, "excludeLowQuantization": { - "label": "Exclude low-bit quantization (FP4/FP6/Int4)", - "description": "Only allow higher precision providers (FP8/FP16/BF16/Int8). Helps prevent broken CJK (Korean/Chinese/Japanese) encoding from aggressively quantized models." + "label": "Lagebit-kwantisatie uitsluiten (FP4/FP6/Int4)", + "description": "Sta alleen hogere-precisieproviders toe (FP8/FP16/BF16/Int8). Helpt problemen met CJK-codering (Koreaans/Chinees/Japans) door agressief gekwantiseerde modellen te voorkomen." } }, "customModel": { diff --git a/webview-ui/src/i18n/locales/pl/settings.json b/webview-ui/src/i18n/locales/pl/settings.json index fa13ac1d3cf..6410b1bb0e2 100644 --- a/webview-ui/src/i18n/locales/pl/settings.json +++ b/webview-ui/src/i18n/locales/pl/settings.json @@ -479,8 +479,8 @@ "learnMore": "Dowiedz się więcej o routingu dostawców" }, "excludeLowQuantization": { - "label": "Exclude low-bit quantization (FP4/FP6/Int4)", - "description": "Only allow higher precision providers (FP8/FP16/BF16/Int8). Helps prevent broken CJK (Korean/Chinese/Japanese) encoding from aggressively quantized models." + "label": "Wyklucz kwantyzację niskich bitów (FP4/FP6/Int4)", + "description": "Zezwalaj tylko na dostawców o wyższej precyzji (FP8/FP16/BF16/Int8). Pomaga zapobiegać problemom z kodowaniem CJK (koreański/chiński/japoński) w agresywnie skwantyzowanych modelach." } }, "customModel": { diff --git a/webview-ui/src/i18n/locales/pt-BR/settings.json b/webview-ui/src/i18n/locales/pt-BR/settings.json index c81a66d681a..728b926724e 100644 --- a/webview-ui/src/i18n/locales/pt-BR/settings.json +++ b/webview-ui/src/i18n/locales/pt-BR/settings.json @@ -479,8 +479,8 @@ "learnMore": "Saiba mais sobre roteamento de provedores" }, "excludeLowQuantization": { - "label": "Exclude low-bit quantization (FP4/FP6/Int4)", - "description": "Only allow higher precision providers (FP8/FP16/BF16/Int8). Helps prevent broken CJK (Korean/Chinese/Japanese) encoding from aggressively quantized models." + "label": "Excluir quantização de baixa precisão (FP4/FP6/Int4)", + "description": "Permitir apenas provedores de maior precisão (FP8/FP16/BF16/Int8). Ajuda a prevenir problemas de codificação CJK (coreano/chinês/japonês) em modelos quantizados agressivamente." } }, "customModel": { diff --git a/webview-ui/src/i18n/locales/ru/settings.json b/webview-ui/src/i18n/locales/ru/settings.json index dc461df1f3f..392b3981491 100644 --- a/webview-ui/src/i18n/locales/ru/settings.json +++ b/webview-ui/src/i18n/locales/ru/settings.json @@ -479,8 +479,8 @@ "learnMore": "Подробнее о маршрутизации провайдеров" }, "excludeLowQuantization": { - "label": "Exclude low-bit quantization (FP4/FP6/Int4)", - "description": "Only allow higher precision providers (FP8/FP16/BF16/Int8). Helps prevent broken CJK (Korean/Chinese/Japanese) encoding from aggressively quantized models." + "label": "Исключить низкобитовую квантизацию (FP4/FP6/Int4)", + "description": "Разрешить только провайдеров с высокой точностью (FP8/FP16/BF16/Int8). Помогает предотвратить проблемы с кодировкой CJK (корейский/китайский/японский) при использовании агрессивно квантизированных моделей." } }, "customModel": { diff --git a/webview-ui/src/i18n/locales/tr/settings.json b/webview-ui/src/i18n/locales/tr/settings.json index 9042a3eba59..41ea2080fa1 100644 --- a/webview-ui/src/i18n/locales/tr/settings.json +++ b/webview-ui/src/i18n/locales/tr/settings.json @@ -479,8 +479,8 @@ "learnMore": "Sağlayıcı yönlendirmesi hakkında daha fazla bilgi edinin" }, "excludeLowQuantization": { - "label": "Exclude low-bit quantization (FP4/FP6/Int4)", - "description": "Only allow higher precision providers (FP8/FP16/BF16/Int8). Helps prevent broken CJK (Korean/Chinese/Japanese) encoding from aggressively quantized models." + "label": "Düşük bit kuantalamayı hariç tut (FP4/FP6/Int4)", + "description": "Yalnızca yüksek hassasiyetli sağlayıcılara izin ver (FP8/FP16/BF16/Int8). Agresif şekilde kuantalanmış modellerden kaynaklanan CJK (Korece/Çince/Japonca) kodlama sorunlarını önlemeye yardımcı olur." } }, "customModel": { diff --git a/webview-ui/src/i18n/locales/vi/settings.json b/webview-ui/src/i18n/locales/vi/settings.json index 6e561901282..aeec0795b79 100644 --- a/webview-ui/src/i18n/locales/vi/settings.json +++ b/webview-ui/src/i18n/locales/vi/settings.json @@ -479,8 +479,8 @@ "learnMore": "Tìm hiểu thêm về định tuyến nhà cung cấp" }, "excludeLowQuantization": { - "label": "Exclude low-bit quantization (FP4/FP6/Int4)", - "description": "Only allow higher precision providers (FP8/FP16/BF16/Int8). Helps prevent broken CJK (Korean/Chinese/Japanese) encoding from aggressively quantized models." + "label": "Loại trừ lượng tử hóa bit thấp (FP4/FP6/Int4)", + "description": "Chỉ cho phép các nhà cung cấp có độ chính xác cao (FP8/FP16/BF16/Int8). Giúp ngăn ngừa lỗi mã hóa CJK (Hàn Quốc/Trung Quốc/Nhật Bản) từ các mô hình được lượng tử hóa mạnh." } }, "customModel": { diff --git a/webview-ui/src/i18n/locales/zh-CN/settings.json b/webview-ui/src/i18n/locales/zh-CN/settings.json index 36aa77b5a7d..048a9a3c5e1 100644 --- a/webview-ui/src/i18n/locales/zh-CN/settings.json +++ b/webview-ui/src/i18n/locales/zh-CN/settings.json @@ -479,8 +479,8 @@ "learnMore": "了解更多" }, "excludeLowQuantization": { - "label": "Exclude low-bit quantization (FP4/FP6/Int4)", - "description": "Only allow higher precision providers (FP8/FP16/BF16/Int8). Helps prevent broken CJK (Korean/Chinese/Japanese) encoding from aggressively quantized models." + "label": "排除低位量化 (FP4/FP6/Int4)", + "description": "仅允许高精度提供商 (FP8/FP16/BF16/Int8)。有助于防止激进量化模型导致的 CJK(韩文/中文/日文)编码问题。" } }, "customModel": { diff --git a/webview-ui/src/i18n/locales/zh-TW/settings.json b/webview-ui/src/i18n/locales/zh-TW/settings.json index a23795bd5c4..b20df1e3d44 100644 --- a/webview-ui/src/i18n/locales/zh-TW/settings.json +++ b/webview-ui/src/i18n/locales/zh-TW/settings.json @@ -489,8 +489,8 @@ "learnMore": "了解更多關於供應商路由的資訊" }, "excludeLowQuantization": { - "label": "Exclude low-bit quantization (FP4/FP6/Int4)", - "description": "Only allow higher precision providers (FP8/FP16/BF16/Int8). Helps prevent broken CJK (Korean/Chinese/Japanese) encoding from aggressively quantized models." + "label": "排除低位元量化 (FP4/FP6/Int4)", + "description": "僅允許高精度供應商 (FP8/FP16/BF16/Int8)。有助於防止激進量化模型導致的 CJK(韓文/中文/日文)編碼問題。" } }, "customModel": { From 3690b887e3a4c19f10e285eed65652939cc00244 Mon Sep 17 00:00:00 2001 From: Roo Code Date: Thu, 26 Feb 2026 06:53:13 +0000 Subject: [PATCH 3/3] refactor: cache buildProviderOptions() result to avoid redundant calls --- src/api/providers/openrouter.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/api/providers/openrouter.ts b/src/api/providers/openrouter.ts index cab2b5b7aa2..ef82cf25377 100644 --- a/src/api/providers/openrouter.ts +++ b/src/api/providers/openrouter.ts @@ -309,6 +309,7 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH } // https://openrouter.ai/docs/transforms + const providerOptions = this.buildProviderOptions() const completionParams: OpenRouterChatCompletionParams = { model: modelId, ...(maxTokens && maxTokens > 0 && { max_tokens: maxTokens }), @@ -317,7 +318,7 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH messages: openAiMessages, stream: true, stream_options: { include_usage: true }, - ...(this.buildProviderOptions() && { provider: this.buildProviderOptions() }), + ...(providerOptions && { provider: providerOptions }), ...(reasoning && { reasoning }), tools: this.convertToolsForOpenAI(metadata?.tools), tool_choice: metadata?.tool_choice, @@ -610,13 +611,14 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH async completePrompt(prompt: string) { let { id: modelId, maxTokens, temperature, reasoning } = await this.fetchModel() + const providerOptions = this.buildProviderOptions() const completionParams: OpenRouterChatCompletionParams = { model: modelId, max_tokens: maxTokens, temperature, messages: [{ role: "user", content: prompt }], stream: false, - ...(this.buildProviderOptions() && { provider: this.buildProviderOptions() }), + ...(providerOptions && { provider: providerOptions }), ...(reasoning && { reasoning }), }