Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.
JavaScript aianthropiccross-platformgeminigroqlinuxmacosnvidiaopen-sourceopenaiparakeetspeech-to-texttranscribewhisperwindows
feat(reasoning): pick a reasoning effort per scope (#2694)
void48cb1001debf
diff --git a/CLAUDE.md b/CLAUDE.mdindex 707af8152..472163d02 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -445,7 +445,7 @@ Non-secret env vars persisted to `.env` (via `saveAllKeysToEnvFile()`):- Gemini 3.5 Flash (`gemini-3.5-flash`) - Latest fast, high-capability Gemini model- Gemini 3.5 Flash Lite (`gemini-3.5-flash-lite`) - Fastest, most cost-effective 3.5 model- Gemini 3.1 Pro (`gemini-3.1-pro-preview`) - Most capable Gemini model- - Gemini 3.1 Flash Lite (`gemini-3.1-flash-lite`) - Frontier-class performance at low cost (no thinking support, so no `supportsThinking` flag)+ - Gemini 3.1 Flash Lite (`gemini-3.1-flash-lite`) - Frontier-class performance at low cost. It thinks, and requests that aren't streamed pin it to `minimal` unless a reasoning effort is picked; it has no `supportsThinking` flag, so Settings shows the effort picker rather than the thinking toggle- Gemini 3 Flash (`gemini-3-flash-preview`) - Ultra-fast, high-capability next-gen model- Gemini 2.5 Flash Lite (`gemini-2.5-flash-lite`) - Lowest latency and cost (retired for new API keys; kept for existing ones)- Gemma 4 (`gemma-4-31b-it`, `gemma-4-26b-a4b-it`) - Google's open Gemma 4 models served through the Gemini APIdiff --git a/src/components/ControlPanel.tsx b/src/components/ControlPanel.tsxindex a543941b2..63cb1bb77 100644--- a/src/components/ControlPanel.tsx+++ b/src/components/ControlPanel.tsx@@ -767,6 +767,7 @@ export default function ControlPanel({ initialSettingsSection }: ControlPanelProconst agentName = getAgentName();const reasonedText = await ReasoningService.processText(rawText, model, agentName, {disableThinking: getSettings().cleanupDisableThinking,+ reasoningEffort: getSettings().cleanupReasoningEffort,requireCompleteOutput: true,});if (hasTextContent(reasonedText) && reasonedText !== rawText) {diff --git a/src/components/chat/useChatStreaming.ts b/src/components/chat/useChatStreaming.tsindex a5b312881..a3e3d6989 100644--- a/src/components/chat/useChatStreaming.ts+++ b/src/components/chat/useChatStreaming.ts@@ -692,6 +692,7 @@ export function useChatStreaming({customApiKey:isCustomAgent || isLanAgent ? llmConfig.customApiKey || undefined : undefined,disableThinking: llmConfig.disableThinking,+ reasoningEffort: llmConfig.reasoningEffort,},aiTools);diff --git a/src/components/settings/InferenceConfigEditor.tsx b/src/components/settings/InferenceConfigEditor.tsxindex 239df3444..261c94924 100644--- a/src/components/settings/InferenceConfigEditor.tsx+++ b/src/components/settings/InferenceConfigEditor.tsx@@ -18,6 +18,7 @@ import ReasoningModelSelector from "../ReasoningModelSelector";import EnterpriseSection from "../EnterpriseSection";import OpenAICompatiblePanel from "../OpenAICompatiblePanel";import { Toggle } from "../ui/toggle";+import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../ui/select";import type { InferenceMode } from "../../types/electron";import {INFERENCE_SCOPES,@@ -30,12 +31,17 @@ import {getLocalModel,enterpriseProviderName,} from "../../models/ModelRegistry";+import { AUTO_REASONING_EFFORT, isReasoningEffortSupported } from "../../models/reasoningEffort";+import { selectableReasoningEffort } from "../../services/ai/chatRequestBody";import { useManagedScopeResolution } from "../../stores/enterpriseIdentityStore";import { requestSignIn } from "../../utils/requestSignIn";import TestConnectionButton from "../TestConnectionButton";import { getEnterpriseCallSettings } from "../../services/ai/enterpriseSettings";import { Button } from "../ui/button";+// Radix Select can't hold an empty value, so Auto ("") gets a sentinel.+const AUTO_REASONING_EFFORT_VALUE = "__auto__";+const MODE_LABEL_PREFIX: Record<InferenceScope, string> = {dictationCleanup: "settingsPage.aiModels.modes",noteFormatting: "settingsPage.aiModels.modes",@@ -182,6 +188,11 @@ export default function InferenceConfigEditor({!!getCloudModel(config.model)?.supportsThinking)) ||(effectiveMode === "local" && !!getLocalModel(config.model)?.supportsThinking);+ const effortCapability =+ effectiveMode === "providers"+ ? selectableReasoningEffort(config.provider, config.model, config, config.cloudBaseUrl)+ : null;+if (managed.kind === "error") {return (<div className="rounded-lg border border-destructive/30 bg-destructive/5 p-3" role="alert">@@ -308,6 +319,54 @@ export default function InferenceConfigEditor({</div>)}+ {effortCapability && (+ <div className="flex items-start justify-between gap-3 pt-1">+ <div className="flex-1 min-w-0">+ <h4 className="text-sm font-medium text-foreground">{t("reasoning.effort.title")}</h4>+ <p className="text-xs text-muted-foreground">+ {effortCapability.defaultValue+ ? t("reasoning.effort.descriptionWithDefault", {+ value: t(`reasoning.effort.options.${effortCapability.defaultValue}`),+ })+ : t("reasoning.effort.description")}+ </p>+ </div>+ <Select+ value={+ isReasoningEffortSupported(effortCapability, config.reasoningEffort)+ ? config.reasoningEffort+ : AUTO_REASONING_EFFORT_VALUE+ }+ onValueChange={(value) =>+ setField("reasoningEffort")(+ value === AUTO_REASONING_EFFORT_VALUE ? AUTO_REASONING_EFFORT : value+ )+ }+ >+ <SelectTrigger className="h-7 w-44 shrink-0 text-xs rounded-lg px-2.5 [&>svg]:h-3 [&>svg]:w-3">+ <SelectValue />+ </SelectTrigger>+ <SelectContent>+ <SelectItem+ value={AUTO_REASONING_EFFORT_VALUE}+ className="text-xs py-1.5 ps-2.5 pe-7 rounded-md"+ >+ {t("reasoning.effort.auto")}+ </SelectItem>+ {effortCapability.options.map((effort) => (+ <SelectItem+ key={effort}+ value={effort}+ className="text-xs py-1.5 ps-2.5 pe-7 rounded-md"+ >+ {t(`reasoning.effort.options.${effort}`)}+ </SelectItem>+ ))}+ </SelectContent>+ </Select>+ </div>+ )}+{effectiveMode === "local" && (<div className="flex items-start justify-between gap-3 pt-1"><div className="flex-1 min-w-0">diff --git a/src/components/ui/PromptStudio.tsx b/src/components/ui/PromptStudio.tsxindex 62339e043..3aaf8386f 100644--- a/src/components/ui/PromptStudio.tsx+++ b/src/components/ui/PromptStudio.tsx@@ -272,6 +272,7 @@ export default function PromptStudio({ className = "", kind = "cleanup" }: Prompconst result = await ReasoningService.processText(testText, modelToUse, agentName, {inferenceScope: "dictationCleanup",disableThinking: effectiveSettings.cleanupDisableThinking,+ reasoningEffort: effectiveSettings.cleanupReasoningEffort,});setTestResult(result);} finally {diff --git a/src/config/inferenceScopes.ts b/src/config/inferenceScopes.tsindex fbaacdcbd..fdd64af3f 100644--- a/src/config/inferenceScopes.ts+++ b/src/config/inferenceScopes.ts@@ -10,6 +10,7 @@ export interface InferenceScopeStoreKeys {remoteUrl?: keyof SettingsState;customApiKey?: keyof SettingsState;disableThinking?: keyof SettingsState;+ reasoningEffort?: keyof SettingsState;}export interface InferenceScopeDefinition {@@ -40,6 +41,7 @@ export const INFERENCE_SCOPES = {remoteUrl: "cleanupRemoteUrl",customApiKey: "cleanupCustomApiKey",disableThinking: "cleanupDisableThinking",+ reasoningEffort: "cleanupReasoningEffort",},},dictationAgent: {@@ -53,6 +55,7 @@ export const INFERENCE_SCOPES = {remoteUrl: "dictationAgentRemoteUrl",customApiKey: "dictationAgentCustomApiKey",disableThinking: "dictationAgentDisableThinking",+ reasoningEffort: "dictationAgentReasoningEffort",},},// Optional override used only when a voice-agent request carries a screen@@ -68,6 +71,7 @@ export const INFERENCE_SCOPES = {cloudBaseUrl: "dictationAgentVisionCloudBaseUrl",customApiKey: "dictationAgentVisionCustomApiKey",disableThinking: "dictationAgentVisionDisableThinking",+ reasoningEffort: "dictationAgentVisionReasoningEffort",},fallbackScope: "dictationAgent",optional: true,@@ -83,6 +87,7 @@ export const INFERENCE_SCOPES = {remoteUrl: "noteFormattingRemoteUrl",customApiKey: "noteFormattingCustomApiKey",disableThinking: "noteFormattingDisableThinking",+ reasoningEffort: "noteFormattingReasoningEffort",},fallbackScope: "dictationCleanup",},@@ -100,6 +105,7 @@ export const INFERENCE_SCOPES = {remoteUrl: "chatAgentRemoteUrl",customApiKey: "chatAgentCustomApiKey",disableThinking: "chatAgentDisableThinking",+ reasoningEffort: "chatAgentReasoningEffort",},},dictationTranslation: {@@ -113,6 +119,7 @@ export const INFERENCE_SCOPES = {remoteUrl: "translationRemoteUrl",customApiKey: "translationCustomApiKey",disableThinking: "translationDisableThinking",+ reasoningEffort: "translationReasoningEffort",},},} as const satisfies Record<string, InferenceScopeDefinition>;diff --git a/src/helpers/audioManager.js b/src/helpers/audioManager.jsindex 230c3f477..a6e8726df 100644--- a/src/helpers/audioManager.js+++ b/src/helpers/audioManager.js@@ -333,6 +333,7 @@ function resolveReasoningRoute(const cleanupConfig = {inferenceScope: /** @type {const} */ ("dictationCleanup"),disableThinking: settings.cleanupDisableThinking,+ reasoningEffort: settings.cleanupReasoningEffort,temperature: cleanupTemperature,requireCompleteOutput: true,};diff --git a/src/helpers/dictationAgentInference.js b/src/helpers/dictationAgentInference.jsindex ea2ba0812..5cacac078 100644--- a/src/helpers/dictationAgentInference.js+++ b/src/helpers/dictationAgentInference.js@@ -29,6 +29,7 @@ export function resolveDictationAgentInference(settings, { isCloudAgent = falseinferenceScope: /** @type {const} */ ("dictationAgent"),provider: managed.provider,disableThinking: settings.dictationAgentDisableThinking,+ reasoningEffort: settings.dictationAgentReasoningEffort,},};}@@ -68,6 +69,7 @@ export function resolveDictationAgentInference(settings, { isCloudAgent = falsecustomApiKey:isCustom || isSelfHosted ? settings.dictationAgentCustomApiKey || undefined : undefined,disableThinking: settings.dictationAgentDisableThinking,+ reasoningEffort: settings.dictationAgentReasoningEffort,},};}@@ -118,6 +120,7 @@ export function resolveDictationAgentVisionInference(settings, { isSignedIn = fabaseUrl: isCustom ? resolved.cloudBaseUrl || undefined : undefined,customApiKey: isCustom ? customApiKey || undefined : undefined,disableThinking: resolved.disableThinking,+ reasoningEffort: resolved.reasoningEffort,},};}@@ -197,6 +200,7 @@ export function resolveChatStreamingInference(cloudBaseUrl: vision.config.baseUrl,customApiKey: vision.config.customApiKey,disableThinking: vision.config.disableThinking,+ reasoningEffort: vision.config.reasoningEffort,},attachScreenContext: true,};diff --git a/src/helpers/dictationTranslationInference.js b/src/helpers/dictationTranslationInference.jsindex e2e5c558c..24af05622 100644--- a/src/helpers/dictationTranslationInference.js+++ b/src/helpers/dictationTranslationInference.js@@ -25,6 +25,7 @@ export function resolveDictationTranslationInference(provider: managed.provider,language: settings.translationTargetLanguage,disableThinking: settings.translationDisableThinking,+ reasoningEffort: settings.translationReasoningEffort,},};}@@ -65,6 +66,7 @@ export function resolveDictationTranslationInference(customApiKey:isCustom || isSelfHosted ? settings.translationCustomApiKey || undefined : undefined,disableThinking: settings.translationDisableThinking,+ reasoningEffort: settings.translationReasoningEffort,},};}diff --git a/src/locales/ar/translation.json b/src/locales/ar/translation.jsonindex 91e0e5d63..c4a76320f 100644--- a/src/locales/ar/translation.json+++ b/src/locales/ar/translation.json@@ -410,6 +410,21 @@"selectModelHint": "لم يتم تحديد أي نموذج بعد — اختر واحدًا من القائمة أدناه.","keyRequiredHint": "مفتاح API مطلوب للاستدلال — أضف واحدًا لاستخدام هذا المزود."},+ "effort": {+ "title": "مستوى الاستدلال",+ "description": "مقدار تفكير النموذج قبل أن يجيب.",+ "descriptionWithDefault": "مقدار تفكير النموذج قبل أن يجيب. يستخدم الوضع التلقائي الإعداد الافتراضي للمزوّد ({{value}}).",+ "auto": "تلقائي",+ "options": {+ "none": "بلا",+ "minimal": "أدنى",+ "low": "منخفض",+ "medium": "متوسط",+ "high": "مرتفع",+ "xhigh": "مرتفع جدًا",+ "max": "أقصى"+ }+ },"getApiKey": "احصل على مفتاح API الخاص بك ←","selectModel": "تحديد النموذج","availableModels": "النماذج المتاحة",diff --git a/src/locales/de/translation.json b/src/locales/de/translation.jsonindex 9583a664e..9782dd2e3 100644--- a/src/locales/de/translation.json+++ b/src/locales/de/translation.json@@ -773,6 +773,21 @@"selectModelHint": "Noch kein Modell ausgewählt — wählen Sie eines aus der Liste unten.","keyRequiredHint": "Für die Inferenz ist ein API-Schlüssel erforderlich — fügen Sie einen hinzu, um diesen Anbieter zu nutzen."},+ "effort": {+ "title": "Denkaufwand",+ "description": "Wie viel das Modell nachdenkt, bevor es antwortet.",+ "descriptionWithDefault": "Wie viel das Modell nachdenkt, bevor es antwortet. Auto verwendet die Standardeinstellung des Anbieters ({{value}}).",+ "auto": "Auto",+ "options": {+ "none": "Keiner",+ "minimal": "Minimal",+ "low": "Niedrig",+ "medium": "Mittel",+ "high": "Hoch",+ "xhigh": "Sehr hoch",+ "max": "Maximal"+ }+ },"getApiKey": "API-Schlüssel holen ->","selectModel": "Modell auswählen","availableModels": "Verfügbare Modelle",diff --git a/src/locales/en/translation.json b/src/locales/en/translation.jsonindex 5ebea019d..7b3d321dd 100644--- a/src/locales/en/translation.json+++ b/src/locales/en/translation.json@@ -773,6 +773,21 @@"selectModelHint": "No model selected yet — choose one from the list below.","keyRequiredHint": "An API key is required for inference — add one to use this provider."},+ "effort": {+ "title": "Reasoning effort",+ "description": "How much the model thinks before it answers.",+ "descriptionWithDefault": "How much the model thinks before it answers. Auto uses the provider's default ({{value}}).",+ "auto": "Auto",+ "options": {+ "none": "None",+ "minimal": "Minimal",+ "low": "Low",+ "medium": "Medium",+ "high": "High",+ "xhigh": "Extra high",+ "max": "Max"+ }+ },"getApiKey": "Get your API key ->","selectModel": "Select Model","availableModels": "Available Models",diff --git a/src/locales/es/translation.json b/src/locales/es/translation.jsonindex 807f4bfa2..163890de6 100644--- a/src/locales/es/translation.json+++ b/src/locales/es/translation.json@@ -773,6 +773,21 @@"selectModelHint": "Aún no hay un modelo seleccionado — elige uno de la lista de abajo.","keyRequiredHint": "Se requiere una clave API para la inferencia — agrega una para usar este proveedor."},+ "effort": {+ "title": "Esfuerzo de razonamiento",+ "description": "Cuánto piensa el modelo antes de responder.",+ "descriptionWithDefault": "Cuánto piensa el modelo antes de responder. Auto usa el valor predeterminado del proveedor ({{value}}).",+ "auto": "Auto",+ "options": {+ "none": "Ninguno",+ "minimal": "Mínimo",+ "low": "Bajo",+ "medium": "Medio",+ "high": "Alto",+ "xhigh": "Muy alto",+ "max": "Máximo"+ }+ },"getApiKey": "Obtener clave API ->","selectModel": "Seleccionar modelo","availableModels": "Modelos disponibles",diff --git a/src/locales/fr/translation.json b/src/locales/fr/translation.jsonindex d2f3b8adb..8fd20867a 100644--- a/src/locales/fr/translation.json+++ b/src/locales/fr/translation.json@@ -773,6 +773,21 @@"selectModelHint": "Aucun modèle sélectionné — choisissez-en un dans la liste ci-dessous.","keyRequiredHint": "Une clé API est requise pour l'inférence — ajoutez-en une pour utiliser ce fournisseur."},+ "effort": {+ "title": "Effort de raisonnement",+ "description": "Le temps de réflexion du modèle avant de répondre.",+ "descriptionWithDefault": "Le temps de réflexion du modèle avant de répondre. Auto utilise la valeur par défaut du fournisseur ({{value}}).",+ "auto": "Auto",+ "options": {+ "none": "Aucun",+ "minimal": "Minimal",+ "low": "Faible",+ "medium": "Moyen",+ "high": "Élevé",+ "xhigh": "Très élevé",+ "max": "Maximum"+ }+ },"getApiKey": "Obtenir la clé API ->","selectModel": "Sélectionner un modèle","availableModels": "Modèles disponibles",diff --git a/src/locales/it/translation.json b/src/locales/it/translation.jsonindex 6fa5a0cd1..12998cfd6 100644--- a/src/locales/it/translation.json+++ b/src/locales/it/translation.json@@ -773,6 +773,21 @@"selectModelHint": "Nessun modello selezionato — scegline uno dall'elenco qui sotto.","keyRequiredHint": "Per l'inferenza è richiesta una chiave API — aggiungine una per usare questo provider."},+ "effort": {+ "title": "Livello di ragionamento",+ "description": "Quanto ragiona il modello prima di rispondere.",+ "descriptionWithDefault": "Quanto ragiona il modello prima di rispondere. Auto usa l'impostazione predefinita del provider ({{value}}).",+ "auto": "Auto",+ "options": {+ "none": "Nessuno",+ "minimal": "Minimo",+ "low": "Basso",+ "medium": "Medio",+ "high": "Alto",+ "xhigh": "Molto alto",+ "max": "Massimo"+ }+ },"getApiKey": "Ottieni la chiave API ->","selectModel": "Seleziona modello","availableModels": "Modelli disponibili",diff --git a/src/locales/ja/translation.json b/src/locales/ja/translation.jsonindex 3ee93e73c..55908555d 100644--- a/src/locales/ja/translation.json+++ b/src/locales/ja/translation.json@@ -773,6 +773,21 @@"selectModelHint": "モデルが未選択です — 下のリストから選択してください。","keyRequiredHint": "推論には API キーが必要です — このプロバイダーを使用するには追加してください。"},+ "effort": {+ "title": "推論の深さ",+ "description": "モデルが回答する前にどれだけ考えるかを設定します。",+ "descriptionWithDefault": "モデルが回答する前にどれだけ考えるかを設定します。自動ではプロバイダーの既定値({{value}})を使用します。",+ "auto": "自動",+ "options": {+ "none": "なし",+ "minimal": "最小",+ "low": "低",+ "medium": "中",+ "high": "高",+ "xhigh": "非常に高い",+ "max": "最大"+ }+ },"getApiKey": "API キーを取得 ->","selectModel": "モデルを選択","availableModels": "利用可能なモデル",diff --git a/src/locales/pt/translation.json b/src/locales/pt/translation.jsonindex c9b829f69..9bcb2f064 100644--- a/src/locales/pt/translation.json+++ b/src/locales/pt/translation.json@@ -752,6 +752,21 @@"selectModelHint": "Nenhum modelo selecionado ainda — escolha um na lista abaixo.","keyRequiredHint": "Uma chave API é necessária para a inferência — adicione uma para usar este provedor."},+ "effort": {+ "title": "Esforço de raciocínio",+ "description": "Quanto o modelo pensa antes de responder.",+ "descriptionWithDefault": "Quanto o modelo pensa antes de responder. Auto usa o padrão do provedor ({{value}}).",+ "auto": "Auto",+ "options": {+ "none": "Nenhum",+ "minimal": "Mínimo",+ "low": "Baixo",+ "medium": "Médio",+ "high": "Alto",+ "xhigh": "Muito alto",+ "max": "Máximo"+ }+ },"getApiKey": "Obter chave API ->","selectModel": "Selecionar modelo","availableModels": "Modelos disponíveis",diff --git a/src/locales/ru/translation.json b/src/locales/ru/translation.jsonindex aa38733f9..76fc112ab 100644--- a/src/locales/ru/translation.json+++ b/src/locales/ru/translation.json@@ -773,6 +773,21 @@"selectModelHint": "Модель ещё не выбрана — выберите её из списка ниже.","keyRequiredHint": "Для инференса требуется API-ключ — добавьте его, чтобы использовать этого провайдера."},+ "effort": {+ "title": "Глубина рассуждений",+ "description": "Сколько модель размышляет перед ответом.",+ "descriptionWithDefault": "Сколько модель размышляет перед ответом. «Авто» использует настройку провайдера по умолчанию ({{value}}).",+ "auto": "Авто",+ "options": {+ "none": "Нет",+ "minimal": "Минимальная",+ "low": "Низкая",+ "medium": "Средняя",+ "high": "Высокая",+ "xhigh": "Очень высокая",+ "max": "Максимальная"+ }+ },"getApiKey": "Получить API-ключ ->","selectModel": "Выберите модель","availableModels": "Доступные модели",diff --git a/src/locales/zh-CN/translation.json b/src/locales/zh-CN/translation.jsonindex 1fe403fb1..4e26dd7d0 100644--- a/src/locales/zh-CN/translation.json+++ b/src/locales/zh-CN/translation.json@@ -773,6 +773,21 @@"selectModelHint": "尚未选择模型 — 请从下方列表中选择一个。","keyRequiredHint": "推理需要 API 密钥 — 请添加密钥以使用此提供商。"},+ "effort": {+ "title": "推理强度",+ "description": "模型在回答前思考的程度。",+ "descriptionWithDefault": "模型在回答前思考的程度。“自动”使用服务商的默认设置({{value}})。",+ "auto": "自动",+ "options": {+ "none": "无",+ "minimal": "极低",+ "low": "低",+ "medium": "中",+ "high": "高",+ "xhigh": "极高",+ "max": "最大"+ }+ },"getApiKey": "获取你的 API Key ->","selectModel": "选择模型","availableModels": "可用模型",diff --git a/src/locales/zh-TW/translation.json b/src/locales/zh-TW/translation.jsonindex d805eeda3..96e7a46e9 100644--- a/src/locales/zh-TW/translation.json+++ b/src/locales/zh-TW/translation.json@@ -773,6 +773,21 @@"selectModelHint": "尚未選擇模型 — 請從下方清單中選擇一個。","keyRequiredHint": "推論需要 API 金鑰 — 請新增金鑰以使用此供應商。"},+ "effort": {+ "title": "推理強度",+ "description": "模型在回答前思考的程度。",+ "descriptionWithDefault": "模型在回答前思考的程度。「自動」使用服務商的預設設定({{value}})。",+ "auto": "自動",+ "options": {+ "none": "無",+ "minimal": "極低",+ "low": "低",+ "medium": "中",+ "high": "高",+ "xhigh": "極高",+ "max": "最大"+ }+ },"getApiKey": "取得 API Key ->","selectModel": "選擇模型","availableModels": "可用模型",diff --git a/src/models/ModelRegistry.ts b/src/models/ModelRegistry.tsindex 92eba21f9..5504bf914 100644--- a/src/models/ModelRegistry.ts+++ b/src/models/ModelRegistry.ts@@ -48,6 +48,12 @@ export interface CloudModelDefinition {supportsVision?: boolean;tokenParam?: "max_tokens" | "max_completion_tokens";supportsTemperature?: boolean;+ reasoningEffort?: ReasoningEffortCapability;+}++export interface ReasoningEffortCapability {+ options: string[];+ defaultValue?: string;}export interface CloudProviderData {diff --git a/src/models/modelRegistryData.json b/src/models/modelRegistryData.jsonindex a72cc641e..0afa897c4 100644--- a/src/models/modelRegistryData.json+++ b/src/models/modelRegistryData.json@@ -433,7 +433,10 @@"descriptionKey": "models.descriptions.cloud.openai_gpt_6_astra","tokenParam": "max_completion_tokens","supportsTemperature": false,- "supportsVision": true+ "supportsVision": true,+ "reasoningEffort": {+ "options": ["low", "medium", "high", "xhigh", "max"]+ }},{"id": "gpt-5.6-sol",@@ -442,7 +445,11 @@"descriptionKey": "models.descriptions.cloud.openai_gpt_5_6_sol","tokenParam": "max_completion_tokens","supportsTemperature": false,- "supportsVision": true+ "supportsVision": true,+ "reasoningEffort": {+ "options": ["none", "low", "medium", "high", "xhigh", "max"],+ "defaultValue": "medium"+ }},{"id": "gpt-5.6-terra",@@ -451,7 +458,11 @@"descriptionKey": "models.descriptions.cloud.openai_gpt_5_6_terra","tokenParam": "max_completion_tokens","supportsTemperature": false,- "supportsVision": true+ "supportsVision": true,+ "reasoningEffort": {+ "options": ["none", "low", "medium", "high", "xhigh", "max"],+ "defaultValue": "medium"+ }},{"id": "gpt-5.6-luna",@@ -460,7 +471,11 @@"descriptionKey": "models.descriptions.cloud.openai_gpt_5_6_luna","tokenParam": "max_completion_tokens","supportsTemperature": false,- "supportsVision": true+ "supportsVision": true,+ "reasoningEffort": {+ "options": ["none", "low", "medium", "high", "xhigh", "max"],+ "defaultValue": "medium"+ }},{"id": "gpt-5.5",@@ -469,7 +484,11 @@"descriptionKey": "models.descriptions.cloud.openai_gpt_5_5","tokenParam": "max_completion_tokens","supportsTemperature": false,- "supportsVision": true+ "supportsVision": true,+ "reasoningEffort": {+ "options": ["none", "low", "medium", "high", "xhigh"],+ "defaultValue": "medium"+ }},{"id": "gpt-5.2",@@ -478,7 +497,11 @@"descriptionKey": "models.descriptions.cloud.openai_gpt_5_2","tokenParam": "max_completion_tokens","supportsTemperature": false,- "supportsVision": true+ "supportsVision": true,+ "reasoningEffort": {+ "options": ["none", "low", "medium", "high", "xhigh"],+ "defaultValue": "none"+ }},{"id": "gpt-5-mini",@@ -487,7 +510,11 @@"descriptionKey": "models.descriptions.cloud.openai_gpt_5_mini","tokenParam": "max_completion_tokens","supportsTemperature": false,- "supportsVision": true+ "supportsVision": true,+ "reasoningEffort": {+ "options": ["minimal", "low", "medium", "high"],+ "defaultValue": "medium"+ }},{"id": "gpt-5-nano",@@ -496,7 +523,11 @@"descriptionKey": "models.descriptions.cloud.openai_gpt_5_nano","tokenParam": "max_completion_tokens","supportsTemperature": false,- "supportsVision": true+ "supportsVision": true,+ "reasoningEffort": {+ "options": ["minimal", "low", "medium", "high"],+ "defaultValue": "medium"+ }},{"id": "gpt-4.1",@@ -631,7 +662,11 @@"description": "Latest fast, high-capability Gemini model","descriptionKey": "models.descriptions.cloud.gemini_gemini_3_5_flash","supportsThinking": true,- "supportsVision": true+ "supportsVision": true,+ "reasoningEffort": {+ "options": ["minimal", "low", "medium", "high"],+ "defaultValue": "medium"+ }},{"id": "gemini-3.5-flash-lite",@@ -639,7 +674,11 @@"description": "Fastest, most cost-effective 3.5 model","descriptionKey": "models.descriptions.cloud.gemini_gemini_3_5_flash_lite","supportsThinking": true,- "supportsVision": true+ "supportsVision": true,+ "reasoningEffort": {+ "options": ["minimal", "low", "medium", "high"],+ "defaultValue": "minimal"+ }},{"id": "gemini-3.1-pro-preview",@@ -647,14 +686,21 @@"description": "Next-gen flagship model for complex reasoning","descriptionKey": "models.descriptions.cloud.gemini_gemini_3_1_pro_preview","supportsThinking": true,- "supportsVision": true+ "supportsVision": true,+ "reasoningEffort": {+ "options": ["low", "medium", "high"],+ "defaultValue": "high"+ }},{"id": "gemini-3.1-flash-lite","name": "Gemini 3.1 Flash Lite","description": "Frontier-class performance at low cost","descriptionKey": "models.descriptions.cloud.gemini_gemini_3_1_flash_lite",- "supportsVision": true+ "supportsVision": true,+ "reasoningEffort": {+ "options": ["minimal", "low", "medium", "high"]+ }},{"id": "gemini-3-flash-preview",@@ -662,7 +708,11 @@"description": "Ultra-fast, high-capability next-gen model","descriptionKey": "models.descriptions.cloud.gemini_gemini_3_flash_preview","supportsThinking": true,- "supportsVision": true+ "supportsVision": true,+ "reasoningEffort": {+ "options": ["minimal", "low", "medium", "high"],+ "defaultValue": "high"+ }},{"id": "gemini-2.5-flash-lite",@@ -694,14 +744,20 @@"name": "GPT-OSS 120B","description": "OpenAI's open-source flagship, 500 T/sec","supportsThinking": true,- "descriptionKey": "models.descriptions.cloud.groq_openai_gpt_oss_120b"+ "descriptionKey": "models.descriptions.cloud.groq_openai_gpt_oss_120b",+ "reasoningEffort": {+ "options": ["low", "medium", "high"]+ }},{"id": "openai/gpt-oss-20b","name": "GPT-OSS 20B","description": "Fast open-source model, 1000 T/sec","supportsThinking": true,- "descriptionKey": "models.descriptions.cloud.groq_openai_gpt_oss_20b"+ "descriptionKey": "models.descriptions.cloud.groq_openai_gpt_oss_20b",+ "reasoningEffort": {+ "options": ["low", "medium", "high"]+ }},{"id": "groq/compound",diff --git a/src/models/reasoningEffort.ts b/src/models/reasoningEffort.tsnew file mode 100644index 000000000..15ce017b6--- /dev/null+++ b/src/models/reasoningEffort.ts@@ -0,0 +1,63 @@+import { getCloudModel, modelRegistry, type ReasoningEffortCapability } from "./ModelRegistry";+import { getModelFamilyConstraints } from "../services/ai/modelFamilyConstraints";+import { matchesHost } from "../utils/urlUtils";++export const AUTO_REASONING_EFFORT = "";++export const OPEN_ENDPOINT_PROVIDERS = new Set(["custom", "openrouter"]);++const OPEN_ENDPOINT_OPTIONS = ["none", "minimal", "low", "medium", "high", "xhigh"];++// Hosts whose levels are fixed by the API whatever the model, from the provider docs.+const HOST_OPTIONS: Array<{ host: string; options: string[] }> = [+ // grok-4.5 and later; reasoning can't be turned off, and grok-4.5 reads xhigh as high.+ { host: "x.ai", options: ["low", "medium", "high", "xhigh"] },+ // DeepSeek rejects "none" (#1260) and folds every other level into low, high or+ // max. Max is left out: the AI SDK's Chat Completions options refuse it.+ { host: "deepseek.com", options: ["low", "high"] },+];++export function getReasoningEffortCapability(+ provider: string,+ model: string,+ endpoint?: string | null+): ReasoningEffortCapability | null {+ // Custom endpoints and OpenRouter serve models the registry may not describe,+ // so they offer the host's levels, else the family's, else the registry's,+ // else the OpenAI-style list. The server's default is unknown, so none is named.+ if (OPEN_ENDPOINT_PROVIDERS.has(provider)) {+ const hostOptions = HOST_OPTIONS.find(({ host }) => matchesHost(endpoint, host))?.options;+ if (hostOptions) return { options: hostOptions };+ const family = getModelFamilyConstraints(model);+ if (family?.omitReasoningParams) return null;+ // A Custom turn streams through the AI SDK's Chat Completions options,+ // which take no "max"; OpenRouter's own reasoning object does.+ const registryOptions = getCloudModel(model, provider)?.reasoningEffort?.options.filter(+ (option) => provider === "openrouter" || OPEN_ENDPOINT_OPTIONS.includes(option)+ );+ return {+ options: family?.reasoningEffort?.options ?? registryOptions ?? OPEN_ENDPOINT_OPTIONS,+ };+ }+ // Only the provider's own entries, so a self-hosted server that serves a+ // registry model id never inherits a level saved for a cloud provider.+ return (+ modelRegistry+ .getCloudProviders()+ .find((cloudProvider) => cloudProvider.id === provider)+ ?.models.find((cloudModel) => cloudModel.id === model)?.reasoningEffort ?? null+ );+}++export function isReasoningEffortSupported(+ capability: ReasoningEffortCapability | null | undefined,+ value: string | null | undefined+): boolean {+ return !!capability && !!value && capability.options.includes(value);+}++export function hasSelectableReasoningEffort(+ capability: ReasoningEffortCapability | null | undefined+): capability is ReasoningEffortCapability {+ return Boolean(capability && capability.options.length > 1);+}diff --git a/src/services/BaseReasoningService.ts b/src/services/BaseReasoningService.tsindex 2c828962d..0320066ab 100644--- a/src/services/BaseReasoningService.ts+++ b/src/services/BaseReasoningService.ts@@ -15,6 +15,7 @@ export interface ReasoningConfig {customApiKey?: string;provider?: string;disableThinking?: boolean;+ reasoningEffort?: string;/** Screenshot attached to voice-agent requests when screen context is on. */screenContext?: ScreenContextImage;/** Suffix-free prompt used when a screenshot-carrying request is retried text-only. */diff --git a/src/services/ReasoningService.ts b/src/services/ReasoningService.tsindex 7af5f0cec..0b6caf7be 100644--- a/src/services/ReasoningService.ts+++ b/src/services/ReasoningService.ts@@ -34,10 +34,12 @@ import {} from "./ai/openaiBase";import {applyChatCompletionsParams,+ chosenReasoningEffort,emptyResponseError,fetchWithParamFallback,isTruncatedFinishReason,truncatedOutputError,+ type ParamFallbackDetails,} from "./ai/chatRequestBody";import { getModelFamilyConstraints } from "./ai/modelFamilyConstraints";import { detectEndpointDialect } from "./ai/thinkingSuppressionDialects";@@ -113,8 +115,7 @@ function assertAgentSessionAllowedByPolicy(provider: string, mode: InferenceMode}function logParamFallback(logEvent: string) {- return (details: { status: number; stripped: string[] }) =>- logger.logReasoning(logEvent, details);+ return (details: ParamFallbackDetails) => logger.logReasoning(logEvent, details);}class ReasoningService extends BaseReasoningService {@@ -364,6 +365,7 @@ class ReasoningService extends BaseReasoningService {}const res = await fetchWithParamFallback(+ endpoint,() =>fetch(endpoint, {method: "POST",@@ -695,6 +697,7 @@ class ReasoningService extends BaseReasoningService {let response: Response;try {response = await fetchWithParamFallback(+ endpoint,() =>fetch(endpoint, {method: "POST",@@ -901,11 +904,14 @@ class ReasoningService extends BaseReasoningService {// OpenRouter ids are never in the local registry, so the supportsThinking// exemption below can't apply — honor the toggle directly.const openrouterDisableThinking = provider === "openrouter" && config.disableThinking === true;+ // No Tinfoil model offers a level, so this needn't wait for the registry refresh below.+ const reasoningEffort = chosenReasoningEffort(aiProvider, model, config, baseURL);// Resolving a Tinfoil model refreshes the registry, so read model config after it.const aiModel = isEnterprise? createEnterpriseChatModel(provider as EnterpriseProvider, model, config.inferenceScope): await getAIModel(aiProvider, model, apiKey, baseURL, {disableThinking: openrouterDisableThinking,+ reasoningEffort: provider === "openrouter" ? reasoningEffort : undefined,});if (abortController.signal.aborted) {@@ -932,6 +938,16 @@ class ReasoningService extends BaseReasoningService {...(needsGeminiMinimalThinking? { google: { thinkingConfig: { thinkingLevel: "minimal", includeThoughts: false } } }: {}),+ ...(reasoningEffort && provider === "groq" ? { groq: { reasoningEffort } } : {}),+ ...(reasoningEffort && provider === "gemini"+ ? { google: { thinkingConfig: { thinkingLevel: reasoningEffort, includeThoughts: false } } }+ : {}),+ // The SDK sends a Responses effort only for model ids it knows as reasoning+ // models; forceReasoning covers newer OpenAI ids such as gpt-6-astra.+ ...(reasoningEffort && provider === "openai"+ ? { openai: { reasoningEffort, forceReasoning: true } }+ : {}),+ ...(reasoningEffort && provider === "custom" ? { openai: { reasoningEffort } } : {}),};const hasProviderOptions = Object.keys(providerOptions).length > 0;diff --git a/src/services/ai/chatRequestBody.ts b/src/services/ai/chatRequestBody.tsindex 7fd3bc6c2..d63546632 100644--- a/src/services/ai/chatRequestBody.ts+++ b/src/services/ai/chatRequestBody.ts@@ -1,5 +1,12 @@import type { ReasoningConfig } from "../BaseReasoningService";-import { getOpenAiApiConfig } from "../../models/ModelRegistry";+import { getOpenAiApiConfig, type ReasoningEffortCapability } from "../../models/ModelRegistry";+import {+ getReasoningEffortCapability,+ hasSelectableReasoningEffort,+ isReasoningEffortSupported,+ OPEN_ENDPOINT_PROVIDERS,+} from "../../models/reasoningEffort";+import { matchesHost } from "../../utils/urlUtils";import { detectEndpointDialect } from "./thinkingSuppressionDialects";import { getModelFamilyConstraints } from "./modelFamilyConstraints";import { applyThinkingSuppression, isThinkingSuppressed } from "./thinkingSuppression";@@ -16,11 +23,11 @@ const LEGACY_CHAT_COMPLETIONS_PROVIDERS = new Set(["local", "lan", "groq", "tinf/*** Single place that turns (model, provider, endpoint, config) into the* parameter set of an OpenAI-compatible chat-completions body: token-limit- * param, temperature, family reasoning effort, and thinking suppression.+ * param, temperature, reasoning effort, and thinking suppression.* Callers own `model`/`messages`/`stream`; this owns every tunable param, so* a family or provider fact changed in the data tables reaches all transports* at once instead of one call site at a time (#1611). Responses bodies get the- * same family effort from familyResponsesEffort; keep the two in step.+ * same effort from responsesReasoningEffort; keep the two in step.*/export function applyChatCompletionsParams(requestBody: Record<string, unknown>,@@ -55,11 +62,17 @@ export function applyChatCompletionsParams(}}- // Deterministic transforms (cleanup, selection edits) pin the family's- // preferred effort — see modelFamilyConstraints for the gpt-oss rationale.- // applyThinkingSuppression still wins when thinking is disabled by the user.+ // The user's chosen effort wins; otherwise deterministic transforms+ // (cleanup, selection edits) pin the family's preferred effort — see+ // modelFamilyConstraints for the gpt-oss rationale. A suppressed request has+ // no chosen effort, so applyThinkingSuppression still decides it.const familyEffort = getModelFamilyConstraints(model)?.reasoningEffort;- if (familyEffort?.cleanupValue && isDeterministicTransform(config)) {+ const effort = chosenReasoningEffort(providerKey, model, config, endpoint);+ if (effort) {+ // OpenRouter takes effort only inside its reasoning object.+ if (providerKey === "openrouter") requestBody.reasoning = { effort };+ else requestBody.reasoning_effort = effort;+ } else if (familyEffort?.cleanupValue && isDeterministicTransform(config)) {requestBody.reasoning_effort = familyEffort.cleanupValue;}@@ -72,24 +85,75 @@ export function applyChatCompletionsParams();// Some dialects suppress through other fields, so a default effort beside// them would contradict the suppression.- if (!suppressed && familyEffort?.defaultValue) {+ if (!suppressed && !effort && familyEffort?.defaultValue) {requestBody.reasoning_effort ??= familyEffort.defaultValue;}}/**- * The family's effort for a Responses API body (`reasoning: { effort }`), by- * the same rules as the chat body above. A model outside the family table- * sends no effort, leaving the server's default.+ * The effort for a Responses API body (`reasoning: { effort }`), by the same+ * rules as the chat body above. Suppression sends the family's floor, or+ * "none" like the generic chat dialect; with no choice, a model outside the+ * family table sends no effort, leaving the server's default.*/-export function familyResponsesEffort(model: string, config: ReasoningConfig): string | undefined {+export function responsesReasoningEffort(+ model: string,+ provider: string,+ config: ReasoningConfig,+ endpoint?: string | null+): string | undefined {const familyEffort = getModelFamilyConstraints(model)?.reasoningEffort;- if (!familyEffort) return undefined;- if (isThinkingSuppressed(model, config)) return familyEffort.suppressValue;- if (familyEffort.cleanupValue && isDeterministicTransform(config)) {+ if (isThinkingSuppressed(model, config)) {+ // Native OpenAI shows no toggle, so its default-on value is not the user's+ // choice: a model id the registry no longer lists keeps the server's default.+ return (+ familyEffort?.suppressValue ?? (provider.toLowerCase() === "openai" ? undefined : "none")+ );+ }+ const effort = chosenReasoningEffort(provider, model, config, endpoint);+ if (effort) return effort;+ if (familyEffort?.cleanupValue && isDeterministicTransform(config)) {return familyEffort.cleanupValue;}- return familyEffort.defaultValue;+ return familyEffort?.defaultValue;+}++/**+ * The levels Settings offers for this provider, model and endpoint, or null+ * when it shows no picker: thinking is suppressed, the toggle Custom and+ * OpenRouter show for every model is on, or the model has fewer than two.+ */+export function selectableReasoningEffort(+ provider: string,+ model: string,+ config: ReasoningConfig,+ endpoint?: string | null+): ReasoningEffortCapability | null {+ const providerKey = provider.toLowerCase();+ if (!model || isThinkingSuppressed(model, config)) return null;+ if (OPEN_ENDPOINT_PROVIDERS.has(providerKey) && config.disableThinking === true) return null;+ const capability = getReasoningEffortCapability(providerKey, model, endpoint);+ return hasSelectableReasoningEffort(capability) ? capability : null;+}++/**+ * The effort the user picked for this scope, when Settings offers it for this+ * provider and model. A stored level it doesn't offer (the model, provider or+ * toggle changed since) is ignored.+ */+export function chosenReasoningEffort(+ provider: string,+ model: string,+ config: ReasoningConfig,+ endpoint?: string | null+): string | undefined {+ const effort = config.reasoningEffort;+ return isReasoningEffortSupported(+ selectableReasoningEffort(provider, model, config, endpoint),+ effort+ )+ ? effort+ : undefined;}function isDeterministicTransform(config: ReasoningConfig): boolean {@@ -147,7 +211,7 @@ export function emptyResponseError(* module's shaping layer added are strippable — never messages or model — so a* retry degrades the request (model reasons when asked not to, default* sampling) instead of failing it outright. The strip is logged loudly: a- * fallback that fires on every request is a dialect bug to fix, not a rescue.+ * fallback that keeps firing is a dialect bug to fix, not a rescue.*/const STRIPPABLE_SHAPED_PARAMS = ["reasoning_effort",@@ -157,39 +221,79 @@ const STRIPPABLE_SHAPED_PARAMS = ["temperature",] as const;+/**+ * Values a server rejected, as `endpoint, model, param=value` → when the+ * memory expires. Keyed by value, so another effort level is still sent; the+ * expiry retries a value once the model behind the endpoint may have changed.+ */+const rejectedParams = new Map<string, number>();+const REJECTION_MEMORY_MS = 10 * 60 * 1000;++/** `remembered`: left out up front because an earlier retry proved it rejected. */+export type ParamFallbackDetails = { status?: number; stripped: string[]; remembered?: true };+/*** Fetch with a bounded param-stripping ladder for 400/422 rejections.* Rung 1 (blind): old Ollama/strict proxies reject the `reasoning` object* without naming it — drop it and retry once. Rung 2 (named): strip exactly* the shaped params the error body names and retry once. At most two retries;* the caller must build the body inside `doFetch` so retries re-serialize.+ * A value the error named whose removal let the retry through is left out of+ * later requests to the same endpoint and model for REJECTION_MEMORY_MS, so+ * each pays the rejection once rather than on every request. OpenRouter is+ * never remembered: it routes each request to one of several upstreams.*/export async function fetchWithParamFallback(+ endpoint: string,doFetch: () => Promise<Response>,requestBody: Record<string, unknown>,- logRejection: (details: { status: number; stripped: string[] }) => void+ logRejection: (details: ParamFallbackDetails) => void): Promise<Response> {+ const rejectionKey = (param: string) =>+ `${endpoint}\n${requestBody.model}\n${param}=${JSON.stringify(requestBody[param])}`;+ const remembered = ["reasoning", ...STRIPPABLE_SHAPED_PARAMS].filter(+ (param) => param in requestBody && (rejectedParams.get(rejectionKey(param)) ?? 0) > Date.now()+ );+ const canRemember = !matchesHost(endpoint, "openrouter.ai");+ if (remembered.length > 0) {+ logRejection({ stripped: remembered, remembered: true });+ for (const param of remembered) delete requestBody[param];+ }+ const readError = (response: Response) =>+ response+ .clone()+ .text()+ .catch(() => "");+ const retryWithout = async (params: readonly string[], remember: boolean) => {+ const keys = params.map(rejectionKey);+ for (const param of params) delete requestBody[param];+ const retried = await doFetch();+ if (remember && canRemember && retried.ok) {+ const expiresAt = Date.now() + REJECTION_MEMORY_MS;+ for (const key of keys) rejectedParams.set(key, expiresAt);+ }+ return retried;+ };+let res = await doFetch();if (res.ok || (res.status !== 400 && res.status !== 422)) return res;if (requestBody.reasoning) {+ // Remembered only when the error names it: a blind 400 may have come from+ // one of several backends behind the same endpoint.+ const reasoningNamed = (await readError(res)).toLowerCase().includes("reasoning");logRejection({ status: res.status, stripped: ["reasoning"] });- delete requestBody.reasoning;void res.body?.cancel();- res = await doFetch();+ res = await retryWithout(["reasoning"], reasoningNamed);if (res.ok || (res.status !== 400 && res.status !== 422)) return res;}- const errorText = await res- .clone()- .text()- .catch(() => "");+ const errorText = await readError(res);const named = STRIPPABLE_SHAPED_PARAMS.filter((p) => p in requestBody && errorText.includes(p));if (named.length > 0) {logRejection({ status: res.status, stripped: named });- for (const param of named) delete requestBody[param];void res.body?.cancel();- res = await doFetch();+ res = await retryWithout(named, true);}return res;}diff --git a/src/services/ai/inferenceProviders/gemini.ts b/src/services/ai/inferenceProviders/gemini.tsindex c22c65d09..fbe5f8e88 100644--- a/src/services/ai/inferenceProviders/gemini.ts+++ b/src/services/ai/inferenceProviders/gemini.ts@@ -7,7 +7,7 @@ import {} from "../../../helpers/llmRequestTimeout.js";import { extractGeminiText } from "../../../helpers/geminiResponse.js";import { wrapCleanupTranscript } from "../../../config/prompts";-import { emptyOutputError, truncatedOutputError } from "../chatRequestBody";+import { chosenReasoningEffort, emptyOutputError, truncatedOutputError } from "../chatRequestBody";import logger from "../../../utils/logger";import {asProviderError,@@ -31,7 +31,7 @@ interface GeminiResponse {interface GeminiGenerationConfig {temperature: number;thinkingConfig?: {- thinkingLevel?: "minimal" | "low";+ thinkingLevel?: string;thinkingBudget?: number;includeThoughts: boolean;};@@ -73,7 +73,12 @@ export const geminiProvider: InferenceProvider = {// limit and the request timeout bound the reply.};- if (config.disableThinking === true && minimalThinking[model]) {+ // A chosen level is only offered while thinking isn't suppressed, so it wins+ // over the minimal floor that a model without the toggle gets by default.+ const thinkingLevel = chosenReasoningEffort("gemini", model, config);+ if (thinkingLevel) {+ generationConfig.thinkingConfig = { thinkingLevel, includeThoughts: false };+ } else if (config.disableThinking === true && minimalThinking[model]) {generationConfig.thinkingConfig = minimalThinking[model];}diff --git a/src/services/ai/inferenceProviders/openai.ts b/src/services/ai/inferenceProviders/openai.tsindex f0f79df66..5b592a19e 100644--- a/src/services/ai/inferenceProviders/openai.ts+++ b/src/services/ai/inferenceProviders/openai.ts@@ -8,9 +8,9 @@ import { canBorrowCleanupCustomKey, resolveConfiguredOpenAIBase } from "../openaimport {applyChatCompletionsParams,emptyResponseError,- familyResponsesEffort,fetchWithParamFallback,isTruncatedFinishReason,+ responsesReasoningEffort,truncatedOutputError,} from "../chatRequestBody";import { detectEndpointDialect } from "../thinkingSuppressionDialects";@@ -275,7 +275,7 @@ export const openaiProvider: InferenceProvider = {if (apiConfig.supportsTemperature) {requestBody.temperature = config.temperature ?? (config.systemPrompt ? 0.3 : 0);}- const effort = familyResponsesEffort(model, config);+ const effort = responsesReasoningEffort(model, resolvedProvider, config, openAiBase);if (effort) requestBody.reasoning = { effort };} else {requestBody.messages = buildMessages(type);@@ -289,6 +289,7 @@ export const openaiProvider: InferenceProvider = {}const res = await fetchWithParamFallback(+ endpoint,() =>fetch(endpoint, {method: "POST",diff --git a/src/services/ai/modelFamilyConstraints.ts b/src/services/ai/modelFamilyConstraints.tsindex 924ecafcd..54ad4a68f 100644--- a/src/services/ai/modelFamilyConstraints.ts+++ b/src/services/ai/modelFamilyConstraints.ts@@ -13,6 +13,8 @@ export interface ModelFamilyConstraints {reasoningEffort?: {/** Value that best approximates "thinking off" for reasoning_effort. */suppressValue: string;+ /** Levels a Custom or OpenRouter endpoint offers for this family. */+ options?: string[];/*** Effort for deterministic transforms (cleanup, selection edits). gpt-oss* defaults to medium; low cuts hidden reasoning tokens (latency) and the@@ -37,22 +39,27 @@ const FAMILIES: Array<ModelFamilyConstraints & { match: RegExp }> = [match: /gpt-oss/,// gpt-oss accepts low|medium|high only; it has no off switch. Confirmed// live on Groq and Tinfoil (#1611): "none" is a 400 on both.- reasoningEffort: { suppressValue: "low", cleanupValue: "low" },+ reasoningEffort: {+ suppressValue: "low",+ cleanupValue: "low",+ options: ["low", "medium", "high"],+ },},{family: "qwen",match: /qwen/,// qwen3 accepts none|default only (Groq's enum; "none" is also what the// generic dialect sends everywhere, so the fact is provider-agnostic).- reasoningEffort: { suppressValue: "none" },+ reasoningEffort: { suppressValue: "none", options: ["none"] },},{family: "glm-5.3",match: /glm[-_]?5[-.]?3/,// GLM-5.3/Flash always reason: low|high|max only, no off switch.// "low" is the closest to off. At the server default, max, a long meeting- // spent the whole 4,096-token notes budget thinking (#2008); at high it fit.- reasoningEffort: { suppressValue: "low", defaultValue: "high" },+ // spent the whole 4,096-token notes budget thinking (#2008); at high it fit,+ // so max isn't offered either.+ reasoningEffort: { suppressValue: "low", defaultValue: "high", options: ["low", "high"] },},{family: "magistral",diff --git a/src/services/ai/providers.ts b/src/services/ai/providers.tsindex 015720591..48b9aab9c 100644--- a/src/services/ai/providers.ts+++ b/src/services/ai/providers.ts@@ -15,23 +15,25 @@ import { openCodeSessionHeaders } from "./openCodeSession";// OpenRouter's reasoning control is a top-level request field the AI SDK// can't emit — inject it at the fetch boundary.-const withDisabledReasoning: typeof fetch = (input, init) => {- if (typeof init?.body === "string") {- try {- const body = JSON.parse(init.body);- body.reasoning = { enabled: false };- init = { ...init, body: JSON.stringify(body) };- } catch {}- }- return fetch(input, init);-};+const withReasoning =+ (reasoning: Record<string, unknown>): typeof fetch =>+ (input, init) => {+ if (typeof init?.body === "string") {+ try {+ const body = JSON.parse(init.body);+ body.reasoning = reasoning;+ init = { ...init, body: JSON.stringify(body) };+ } catch {}+ }+ return fetch(input, init);+ };export async function getAIModel(provider: string,model: string,apiKey: string,baseURL?: string,- opts?: { disableThinking?: boolean }+ opts?: { disableThinking?: boolean; reasoningEffort?: string }): Promise<LanguageModel> {switch (provider) {case "openai":@@ -62,13 +64,19 @@ export async function getAIModel(baseURL,headers: openCodeSessionHeaders(baseURL),}).chat(model);- case "openrouter":+ case "openrouter": {+ const reasoning = opts?.disableThinking+ ? { enabled: false }+ : opts?.reasoningEffort+ ? { effort: opts.reasoningEffort }+ : null;// OpenRouter implements Chat Completions, not the OpenAI Responses API.return createOpenAI({apiKey,baseURL,- ...(opts?.disableThinking ? { fetch: withDisabledReasoning } : {}),+ ...(reasoning ? { fetch: withReasoning(reasoning) } : {}),}).chat(model);+ }case "local":return createOpenAI({ apiKey: apiKey || "no-key", baseURL }).chat(model);default:diff --git a/src/stores/actionProcessingStore.ts b/src/stores/actionProcessingStore.tsindex 63d04207e..fa8191ac7 100644--- a/src/stores/actionProcessingStore.ts+++ b/src/stores/actionProcessingStore.ts@@ -499,6 +499,7 @@ export function runBackgroundAction(maxTokens: rewritesSummary ? 2 * NOTE_OUTPUT_MAX_TOKENS : NOTE_OUTPUT_MAX_TOKENS,temperature: 0.3,disableThinking: settings.noteFormattingDisableThinking,+ reasoningEffort: settings.noteFormattingReasoningEffort,// A local model that shrinks the reply to fit the prompt refuses a reply// that fills the shrunken allowance, so a recording is summarised in// parts rather than saved clipped. A plain note has no parts route, sodiff --git a/src/stores/settingsStore.ts b/src/stores/settingsStore.tsindex eac85f35e..dec4a3994 100644--- a/src/stores/settingsStore.ts+++ b/src/stores/settingsStore.ts@@ -978,6 +978,7 @@ export interface SettingsStatetranslationRemoteUrl: string;translationCustomApiKey: string;translationDisableThinking: boolean;+ translationReasoningEffort: string;useDictationTranslation: boolean;translationSourceLanguage: string;translationTargetLanguage: string;@@ -1008,6 +1009,11 @@ export interface SettingsStatedictationAgentVisionDisableThinking: boolean;noteFormattingDisableThinking: boolean;chatAgentDisableThinking: boolean;+ cleanupReasoningEffort: string;+ dictationAgentReasoningEffort: string;+ dictationAgentVisionReasoningEffort: string;+ noteFormattingReasoningEffort: string;+ chatAgentReasoningEffort: string;customPrompts: Record<PromptKind, string>;setCustomPrompt: (kind: PromptKind, value: string) => void;@@ -1806,6 +1812,7 @@ export const useSettingsStore = create<SettingsState>()((set, get) => ({translationRemoteUrl: readString("translationRemoteUrl", ""),translationCustomApiKey: readString("translationCustomApiKey", ""),translationDisableThinking: readBoolean("translationDisableThinking", true),+ translationReasoningEffort: readString("translationReasoningEffort", ""),useDictationTranslation: readBoolean("useDictationTranslation", false),translationSourceLanguage: readString("translationSourceLanguage", "auto"),translationTargetLanguage: readString("translationTargetLanguage", ""),@@ -1954,6 +1961,11 @@ export const useSettingsStore = create<SettingsState>()((set, get) => ({dictationAgentVisionDisableThinking: readBoolean("dictationAgentVisionDisableThinking", true),noteFormattingDisableThinking: readBoolean("noteFormattingDisableThinking", true),chatAgentDisableThinking: readBoolean("chatAgentDisableThinking", true),+ cleanupReasoningEffort: readString("cleanupReasoningEffort", ""),+ dictationAgentReasoningEffort: readString("dictationAgentReasoningEffort", ""),+ dictationAgentVisionReasoningEffort: readString("dictationAgentVisionReasoningEffort", ""),+ noteFormattingReasoningEffort: readString("noteFormattingReasoningEffort", ""),+ chatAgentReasoningEffort: readString("chatAgentReasoningEffort", ""),customPrompts: PROMPT_KIND_LIST.reduce((acc, kind) => ({ ...acc, [kind]: readString(`customPrompt.${kind}`, "") }),@@ -2881,6 +2893,7 @@ export interface ResolvedLLMConfig {remoteUrl?: string;customApiKey?: string;disableThinking: boolean;+ reasoningEffort?: string;}export const selectResolvedLLMConfig = (@@ -2914,6 +2927,7 @@ export const selectResolvedLLMConfig = (// belongs on the request path — see selectResolvedNoteFormatting.customApiKey: read("customApiKey"),disableThinking,+ reasoningEffort: read("reasoningEffort"),};const managed = getManagedScopeResolution(scope, state.enterpriseSetupMode);if (managed.kind === "error") {diff --git a/src/utils/generateTitle.ts b/src/utils/generateTitle.tsindex 70b45f12b..4460c43ad 100644--- a/src/utils/generateTitle.ts+++ b/src/utils/generateTitle.ts@@ -17,6 +17,7 @@ export async function generateNoteTitle(inferenceScope: "noteFormatting",temperature: 0.3,disableThinking: getSettings().noteFormattingDisableThinking,+ reasoningEffort: getSettings().noteFormattingReasoningEffort,...config,});return sanitizeGeneratedTitle(raw);diff --git a/test/helpers/cleanupRouteConfig.test.js b/test/helpers/cleanupRouteConfig.test.jsindex e0258e427..2e9b5419c 100644--- a/test/helpers/cleanupRouteConfig.test.js+++ b/test/helpers/cleanupRouteConfig.test.js@@ -46,7 +46,11 @@ async function loadRouteResolver(t, provider = "test", mode = "providers") {`,},});- const settings = { useCleanupModel: true, cleanupDisableThinking: true };+ const settings = {+ useCleanupModel: true,+ cleanupDisableThinking: true,+ cleanupReasoningEffort: "medium",+ };const resolveReasoningRoute = (await vite.ssrLoadModule("/helpers/audioManager.js")).resolveReasoningRoute;return (text, { voiceAgentRequested = false, translationRequested = false } = {}) =>@@ -62,6 +66,7 @@ test("the cleanup route pins temperature 0 and requires complete output", asyncassert.equal(route.config.inferenceScope, "dictationCleanup");assert.equal(route.config.temperature, 0);assert.equal(route.config.requireCompleteOutput, true);+ assert.equal(route.config.reasoningEffort, "medium");});test("the translation chain's cleanup step pins the same config", async (t) => {diff --git a/test/helpers/dictationAgentInference.test.js b/test/helpers/dictationAgentInference.test.jsindex a80320713..da4326018 100644--- a/test/helpers/dictationAgentInference.test.js+++ b/test/helpers/dictationAgentInference.test.js@@ -12,6 +12,7 @@ const baseSettings = {dictationAgentCloudBaseUrl: "",dictationAgentCustomApiKey: "",dictationAgentDisableThinking: true,+ dictationAgentReasoningEffort: "high",};test("uses the dictation agent scope, not the cleanup scope", async () => {@@ -22,10 +23,12 @@ test("uses the dictation agent scope, not the cleanup scope", async () => {// Cleanup is configured completely differently; it must not leak through.cleanupProvider: "openai",cleanupModel: "gpt-4.1-mini",+ cleanupReasoningEffort: "low",});assert.equal(result.model, "gpt-5-mini");assert.equal(result.config.provider, "openai");+ assert.equal(result.config.reasoningEffort, "high");});test("a model-required agent is unreachable without an explicit model", async () => {@@ -242,9 +245,11 @@ test("vision override runs as the dictation agent scope and inherits key with endictationAgentVisionModel: "vision-model",dictationAgentVisionCloudBaseUrl: "",dictationAgentVisionCustomApiKey: "",+ dictationAgentVisionReasoningEffort: "low",});assert.equal(result.config.inferenceScope, "dictationAgent");+ assert.equal(result.config.reasoningEffort, "low", "the vision scope keeps its own effort");assert.equal(result.config.baseUrl, "https://agent.example.com/v1");assert.equal(result.config.customApiKey,diff --git a/test/helpers/dictationTranslationInference.test.js b/test/helpers/dictationTranslationInference.test.jsindex b4c787b35..a106a6faa 100644--- a/test/helpers/dictationTranslationInference.test.js+++ b/test/helpers/dictationTranslationInference.test.js@@ -13,6 +13,7 @@ const baseSettings = {translationCloudBaseUrl: "",translationCustomApiKey: "",translationDisableThinking: true,+ translationReasoningEffort: "low",};test("providers mode keeps its explicit provider and translation settings", async () => {@@ -25,6 +26,7 @@ test("providers mode keeps its explicit provider and translation settings", asynassert.equal(result.config.provider, "openai");assert.equal(result.config.language, "es");assert.equal(result.config.disableThinking, true);+ assert.equal(result.config.reasoningEffort, "low");});test("local mode routes to llama.cpp with an empty stored provider", async () => {@@ -171,9 +173,8 @@ test("enterprise mode without a provider fails closed", async () => {test("managed enterprise access supplies the provider and model, ignoring manual settings", async (t) => {const { resolveDictationTranslationInference } = await load();- const { useEnterpriseIdentityStore } = await import(- "../../src/stores/enterpriseIdentityStore.ts"- );+ const { useEnterpriseIdentityStore } =+ await import("../../src/stores/enterpriseIdentityStore.ts");const scopes = ["dictationCleanup",diff --git a/test/services/fetchWithParamFallback.test.js b/test/services/fetchWithParamFallback.test.jsindex 8f243c3b5..c3db2e368 100644--- a/test/services/fetchWithParamFallback.test.js+++ b/test/services/fetchWithParamFallback.test.js@@ -20,12 +20,19 @@ function fetcher(...specs) {return doFetch;}+// Rejections are remembered per endpoint for the module's lifetime, so each+// test talks to its own endpoint.+let endpoints = 0;+const nextEndpoint = () => `https://host-${++endpoints}.example/v1/chat/completions`;+test("2xx passes through with a single attempt", async () => {const { fetchWithParamFallback } = await load();const doFetch = fetcher(jsonResponse(200, { ok: true }));const body = { reasoning: { effort: "none" } };- const res = await fetchWithParamFallback(doFetch, body, () => assert.fail("no fallback"));+ const res = await fetchWithParamFallback(nextEndpoint(), doFetch, body, () =>+ assert.fail("no fallback")+ );assert.equal(res.status, 200);assert.equal(doFetch.count(), 1);assert.ok(body.reasoning, "body untouched on success");@@ -37,7 +44,7 @@ test("400 with a reasoning object strips it blind and retries (old Ollama proxieconst body = { reasoning: { effort: "none" }, max_tokens: 10 };const logged = [];- const res = await fetchWithParamFallback(doFetch, body, (d) => logged.push(d));+ const res = await fetchWithParamFallback(nextEndpoint(), doFetch, body, (d) => logged.push(d));assert.equal(res.status, 200);assert.equal(doFetch.count(), 2);assert.ok(!("reasoning" in body));@@ -53,7 +60,7 @@ test("400 naming a shaped param strips exactly that param and retries (#1611 claconst body = { reasoning_effort: "none", chat_template_kwargs: {}, max_tokens: 10 };const logged = [];- const res = await fetchWithParamFallback(doFetch, body, (d) => logged.push(d));+ const res = await fetchWithParamFallback(nextEndpoint(), doFetch, body, (d) => logged.push(d));assert.equal(res.status, 200);assert.ok(!("reasoning_effort" in body));assert.ok("chat_template_kwargs" in body, "unnamed params stay");@@ -69,7 +76,7 @@ test("422 naming temperature strips it (#1417 class)", async () => {);const body = { temperature: 0.3, max_tokens: 10 };- const res = await fetchWithParamFallback(doFetch, body, () => {});+ const res = await fetchWithParamFallback(nextEndpoint(), doFetch, body, () => {});assert.equal(res.status, 200);assert.ok(!("temperature" in body));});@@ -79,7 +86,9 @@ test("400 naming nothing strippable returns the failure without retrying", asyncconst doFetch = fetcher(jsonResponse(400, { error: "model not found" }));const body = { max_tokens: 10 };- const res = await fetchWithParamFallback(doFetch, body, () => assert.fail("no fallback"));+ const res = await fetchWithParamFallback(nextEndpoint(), doFetch, body, () =>+ assert.fail("no fallback")+ );assert.equal(res.status, 400);assert.equal(doFetch.count(), 1);});@@ -89,7 +98,7 @@ test("the ladder is bounded: at most two retries even when everything fails", asconst doFetch = fetcher(jsonResponse(400, { error: "reasoning_effort and thinking rejected" }));const body = { reasoning: {}, reasoning_effort: "low", thinking: { type: "disabled" } };- const res = await fetchWithParamFallback(doFetch, body, () => {});+ const res = await fetchWithParamFallback(nextEndpoint(), doFetch, body, () => {});assert.equal(res.status, 400);assert.equal(doFetch.count(), 3);});@@ -99,8 +108,169 @@ test("non-4xx server errors never trigger stripping", async () => {const doFetch = fetcher(jsonResponse(500, { error: "reasoning_effort exploded" }));const body = { reasoning_effort: "low" };- const res = await fetchWithParamFallback(doFetch, body, () => assert.fail("no fallback"));+ const res = await fetchWithParamFallback(nextEndpoint(), doFetch, body, () =>+ assert.fail("no fallback")+ );assert.equal(res.status, 500);assert.equal(doFetch.count(), 1);assert.ok("reasoning_effort" in body);});++const REASONING_REJECTED = { error: { message: "Unsupported parameter: 'reasoning.effort'" } };++test("a value the retry proved rejected is left out of later requests", async () => {+ const { fetchWithParamFallback } = await load();+ const endpoint = nextEndpoint();+ const rejecting = fetcher(jsonResponse(400, REASONING_REJECTED), jsonResponse(200, {}));+ await fetchWithParamFallback(+ endpoint,+ rejecting,+ { model: "m", reasoning: { effort: "none" } },+ () => {}+ );++ const doFetch = fetcher(jsonResponse(200, {}));+ const body = { model: "m", reasoning: { effort: "none" }, max_tokens: 10 };+ const logged = [];+ const res = await fetchWithParamFallback(endpoint, doFetch, body, (d) => logged.push(d));+ assert.equal(res.status, 200);+ assert.equal(doFetch.count(), 1);+ assert.ok(!("reasoning" in body));+ assert.ok("max_tokens" in body);+ assert.deepEqual(logged, [{ stripped: ["reasoning"], remembered: true }]);+});++test("another value, model or endpoint is still sent after a rejection", async () => {+ const { fetchWithParamFallback } = await load();+ const endpoint = nextEndpoint();+ await fetchWithParamFallback(+ endpoint,+ fetcher(jsonResponse(400, REASONING_REJECTED), jsonResponse(200, {})),+ { model: "m", reasoning: { effort: "none" } },+ () => {}+ );++ for (const [target, body] of [+ [endpoint, { model: "m", reasoning: { effort: "low" } }],+ [endpoint, { model: "other", reasoning: { effort: "none" } }],+ [nextEndpoint(), { model: "m", reasoning: { effort: "none" } }],+ ]) {+ await fetchWithParamFallback(target, fetcher(jsonResponse(200, {})), body, () => {});+ assert.ok("reasoning" in body, JSON.stringify(body));+ }+});++test("a named param is remembered once the retry without it succeeds", async () => {+ const { fetchWithParamFallback } = await load();+ const endpoint = nextEndpoint();+ await fetchWithParamFallback(+ endpoint,+ fetcher(+ jsonResponse(400, { error: "Unrecognized request argument: chat_template_kwargs" }),+ jsonResponse(200, {})+ ),+ { model: "m", reasoning_effort: "none", chat_template_kwargs: { enable_thinking: false } },+ () => {}+ );++ const body = {+ model: "m",+ reasoning_effort: "none",+ chat_template_kwargs: { enable_thinking: false },+ };+ const doFetch = fetcher(jsonResponse(200, {}));+ const logged = [];+ await fetchWithParamFallback(endpoint, doFetch, body, (d) => logged.push(d));+ assert.equal(doFetch.count(), 1);+ assert.deepEqual(logged, [{ stripped: ["chat_template_kwargs"], remembered: true }]);+ assert.ok(!("chat_template_kwargs" in body));+ assert.equal(body.reasoning_effort, "none", "only the rejected param is left out");+});++test("a rejection that doesn't name reasoning is not remembered", async () => {+ // It may have come from one of several backends behind the same endpoint.+ const { fetchWithParamFallback } = await load();+ const endpoint = nextEndpoint();+ await fetchWithParamFallback(+ endpoint,+ fetcher(jsonResponse(400, { error: "bad request" }), jsonResponse(200, {})),+ { model: "m", reasoning: { effort: "none" } },+ () => {}+ );++ const body = { model: "m", reasoning: { effort: "none" } };+ await fetchWithParamFallback(endpoint, fetcher(jsonResponse(200, {})), body, () => {});+ assert.ok("reasoning" in body);+});++test("an error naming Reasoning in any case is remembered", async () => {+ const { fetchWithParamFallback } = await load();+ const endpoint = nextEndpoint();+ await fetchWithParamFallback(+ endpoint,+ fetcher(+ jsonResponse(400, { error: "Reasoning is not supported for this model" }),+ jsonResponse(200, {})+ ),+ { model: "m", reasoning: { effort: "none" } },+ () => {}+ );++ const body = { model: "m", reasoning: { effort: "none" } };+ const doFetch = fetcher(jsonResponse(200, {}));+ await fetchWithParamFallback(endpoint, doFetch, body, () => {});+ assert.ok(!("reasoning" in body));+ assert.equal(doFetch.count(), 1);+});++test("OpenRouter rejections are never remembered: each request may reach another upstream", async () => {+ const { fetchWithParamFallback } = await load();+ const endpoint = "https://openrouter.ai/api/v1/chat/completions";+ await fetchWithParamFallback(+ endpoint,+ fetcher(jsonResponse(400, REASONING_REJECTED), jsonResponse(200, {})),+ { model: "m", reasoning: { effort: "high" } },+ () => {}+ );++ const body = { model: "m", reasoning: { effort: "high" } };+ await fetchWithParamFallback(endpoint, fetcher(jsonResponse(200, {})), body, () => {});+ assert.deepEqual(body.reasoning, { effort: "high" });+});++test("a remembered rejection expires after ten minutes", async (t) => {+ const { fetchWithParamFallback } = await load();+ t.mock.timers.enable({ apis: ["Date"], now: 1_000_000 });+ const endpoint = nextEndpoint();+ await fetchWithParamFallback(+ endpoint,+ fetcher(jsonResponse(400, REASONING_REJECTED), jsonResponse(200, {})),+ { model: "m", reasoning: { effort: "none" } },+ () => {}+ );++ t.mock.timers.tick(10 * 60 * 1000 - 1);+ const stillRemembered = { model: "m", reasoning: { effort: "none" } };+ await fetchWithParamFallback(endpoint, fetcher(jsonResponse(200, {})), stillRemembered, () => {});+ assert.ok(!("reasoning" in stillRemembered));++ t.mock.timers.tick(1);+ const expired = { model: "m", reasoning: { effort: "none" } };+ await fetchWithParamFallback(endpoint, fetcher(jsonResponse(200, {})), expired, () => {});+ assert.ok("reasoning" in expired);+});++test("nothing is remembered when the retry fails too", async () => {+ const { fetchWithParamFallback } = await load();+ const endpoint = nextEndpoint();+ await fetchWithParamFallback(+ endpoint,+ fetcher(jsonResponse(400, REASONING_REJECTED)),+ { model: "m", reasoning: { effort: "none" } },+ () => {}+ );++ const body = { model: "m", reasoning: { effort: "none" } };+ await fetchWithParamFallback(endpoint, fetcher(jsonResponse(200, {})), body, () => {});+ assert.ok("reasoning" in body);+});diff --git a/test/services/llmRequestShapeMatrix.test.js b/test/services/llmRequestShapeMatrix.test.jsindex 8e7323d38..37f18de9a 100644--- a/test/services/llmRequestShapeMatrix.test.js+++ b/test/services/llmRequestShapeMatrix.test.js@@ -89,6 +89,30 @@ const MATRIX = [["corti keeps the legacy chat-completions shape", "Corti", "corti-s1", null, AGENT,{ max_tokens: MAX_TOKENS, temperature: 0.3 }],+ // --- Chosen reasoning effort (the per-scope picker) ---+ ["groq gpt-oss: a chosen effort replaces the cleanup pin", "Groq", "openai/gpt-oss-120b", null, { disableThinking: false, reasoningEffort: "high" },+ { max_tokens: MAX_TOKENS, temperature: 0, reasoning_effort: "high" }],+ ["groq gpt-oss: suppression beats a chosen effort", "Groq", "openai/gpt-oss-120b", null, { disableThinking: true, reasoningEffort: "high" },+ { max_tokens: MAX_TOKENS, temperature: 0, reasoning_effort: "low" }],+ ["groq gpt-oss: a level the model doesn't offer is ignored", "Groq", "openai/gpt-oss-120b", null, { ...AGENT, disableThinking: false, reasoningEffort: "none" },+ { max_tokens: MAX_TOKENS, temperature: 0.3 }],+ ["custom endpoint sends a chosen effort as reasoning_effort (#791)", "custom", "grok-4.3", "https://api.x.ai/v1", { ...AGENT, disableThinking: false, reasoningEffort: "low" },+ { max_completion_tokens: MAX_TOKENS, reasoning_effort: "low" }],+ ["custom x.ai: a level its host doesn't take is never sent", "custom", "grok-4.7", "https://api.x.ai/v1", { ...AGENT, disableThinking: false, reasoningEffort: "minimal" },+ { max_completion_tokens: MAX_TOKENS }],+ ["custom deepseek: none is never sent (#1260)", "custom", "deepseek-chat", "https://api.deepseek.com", { ...AGENT, disableThinking: false, reasoningEffort: "none" },+ { max_tokens: MAX_TOKENS, temperature: 0.3 }],+ ["custom with a registry model: a level the registry doesn't list is never sent", "custom", "gpt-5.5", "https://custom.example/v1", { ...AGENT, disableThinking: false, reasoningEffort: "minimal" },+ { max_completion_tokens: MAX_TOKENS }],+ ["openrouter puts a chosen effort in its reasoning object", "openrouter", "openai/gpt-4o", null, { ...AGENT, disableThinking: false, reasoningEffort: "high" },+ { max_tokens: MAX_TOKENS, temperature: 0.3, reasoning: { effort: "high" } }],+ ["openrouter glm-5.3: a chosen effort sends no family default beside it", "openrouter", "z-ai/glm-5.3", null, { ...AGENT, disableThinking: false, reasoningEffort: "low" },+ { max_tokens: MAX_TOKENS, temperature: 0.3, reasoning: { effort: "low" } }],+ ["custom gpt-oss: a level its family rejects is never sent (#1611)", "custom", "gpt-oss-120b", "https://custom.example/v1", { ...AGENT, disableThinking: false, reasoningEffort: "none" },+ { max_tokens: MAX_TOKENS, temperature: 0.3 }],+ ["self-hosted never sends a level saved for a cloud provider", "lan", "openai/gpt-oss-120b", null, { disableThinking: false, reasoningEffort: "high" },+ { max_tokens: MAX_TOKENS, temperature: 0, reasoning_effort: "low" }],+// --- Gemini through its OpenAI-compat endpoint (agent streaming route) ---["gemini openai-compat: fallback config, no temperature param", "gemini", "gemini-3-flash-preview", null, AGENT,{ max_completion_tokens: MAX_TOKENS }],diff --git a/test/services/modelFamilyConstraints.test.js b/test/services/modelFamilyConstraints.test.jsindex d05d0163d..77899fdf9 100644--- a/test/services/modelFamilyConstraints.test.js+++ b/test/services/modelFamilyConstraints.test.js@@ -21,7 +21,11 @@ test("unknown, empty, and missing ids resolve to no constraints", async () => {test("gpt-oss has no reasoning off switch: suppress and cleanup both floor at low", async () => {const { getModelFamilyConstraints } = await load();const effort = getModelFamilyConstraints("gpt-oss-120b")?.reasoningEffort;- assert.deepEqual(effort, { suppressValue: "low", cleanupValue: "low" });+ assert.deepEqual(effort, {+ suppressValue: "low",+ cleanupValue: "low",+ options: ["low", "medium", "high"],+ });});test("glm-5.3 always reasons: suppress floors at low, high stands in for the server's max", async () => {@@ -29,6 +33,7 @@ test("glm-5.3 always reasons: suppress floors at low, high stands in for the serassert.deepEqual(getModelFamilyConstraints("glm-5.3")?.reasoningEffort, {suppressValue: "low",defaultValue: "high",+ options: ["low", "high"],});assert.equal(getModelFamilyConstraints("glm-5.3-flash")?.family, "glm-5.3");assert.equal(getModelFamilyConstraints("glm-5-3")?.family, "glm-5.3");diff --git a/test/services/openaiReasoningOutput.test.js b/test/services/openaiReasoningOutput.test.jsindex 526a0730b..09542389b 100644--- a/test/services/openaiReasoningOutput.test.js+++ b/test/services/openaiReasoningOutput.test.js@@ -197,13 +197,72 @@ test("Responses requests carry the other families' effort facts too", async (t)assert.deepEqual(bodies[1].reasoning, { effort: "none" });});-test("a model outside the family table gets no reasoning param on a Responses endpoint", async (t) => {+test("a model outside the family table gets the generic off value on a Responses endpoint", async (t) => {const bodies = installFetch(t, () => completeMessage("# Notes"));const { openaiProvider } = await load();await openaiProvider.call({ ...glmNotesCall({ disableThinking: true }), model: "glm-5.2" });+ await openaiProvider.call({ ...glmNotesCall({ disableThinking: false }), model: "glm-5.2" });- assert.equal(bodies[0].reasoning, undefined);+ // "none", as the chat body's generic dialect sends (#791); thinking on leaves the default.+ assert.deepEqual(bodies[0].reasoning, { effort: "none" });+ assert.equal(bodies[1].reasoning, undefined);+});++test("a chosen level on a Responses endpoint is checked against the endpoint's host", async (t) => {+ const bodies = installFetch(t, () => completeMessage("Cleaned."));+ const { openaiProvider } = await load();+ const xaiCall = (reasoningEffort) => ({+ text: "raw transcript",+ model: "grok-4.7",+ agentName: null,+ config: {+ provider: "custom",+ baseUrl: "https://api.x.ai/v1",+ customApiKey: "test-key",+ disableThinking: false,+ reasoningEffort,+ },+ ctx: makeCtx(),+ });++ await openaiProvider.call(xaiCall("xhigh"));+ // x.ai takes no "minimal", so it's left at the server's default.+ await openaiProvider.call(xaiCall("minimal"));++ assert.deepEqual(bodies[0].reasoning, { effort: "xhigh" });+ assert.equal(bodies[1].reasoning, undefined);+});++test("a Custom endpoint that rejects the off value pays the 400 once, not on every request", async (t) => {+ // e.g. Azure OpenAI with a non-reasoning deployment, whose name we can't recognise.+ const bodies = installFetch(t, (body) =>+ body.reasoning+ ? jsonResponse({ error: { message: "Unsupported parameter: 'reasoning.effort'" } }, 400)+ : completeMessage("Cleaned.")+ );+ const { openaiProvider } = await load();+ const cleanup = () =>+ openaiProvider.call({+ text: "raw transcript",+ model: "gpt-4o-prod",+ agentName: null,+ config: {+ provider: "custom",+ baseUrl: "https://rejecting-host.example/v1",+ customApiKey: "test-key",+ disableThinking: true,+ },+ ctx: makeCtx(),+ });++ assert.equal(await cleanup(), "Cleaned.");+ assert.equal(await cleanup(), "Cleaned.");++ assert.deepEqual(+ bodies.map((body) => body.reasoning),+ [{ effort: "none" }, undefined, undefined]+ );});test("a Responses result that ran out of tokens before any text is an error, not the input echoed back", async (t) => {diff --git a/test/services/reasoningEffortRequests.test.js b/test/services/reasoningEffortRequests.test.jsnew file mode 100644index 000000000..e81dc2428--- /dev/null+++ b/test/services/reasoningEffortRequests.test.js@@ -0,0 +1,344 @@+const test = require("node:test");+const assert = require("node:assert/strict");+const path = require("node:path");+const { createRendererServer, installBrowserGlobals } = require("../lib/rendererTestHarness");++// The per-scope reasoning effort must reach every transport a scope can use:+// the Responses API body, Gemini's native thinkingConfig, and the AI SDK+// streaming requests behind the assistant panel and typed chat.++const CHOSEN = (reasoningEffort, extra = {}) => ({+ disableThinking: false,+ reasoningEffort,+ ...extra,+});++test("picker: offered for a registry model even with the toggle at its default", async () => {+ const { selectableReasoningEffort } = await import("../../src/services/ai/chatRequestBody.ts");++ assert.deepEqual(selectableReasoningEffort("openai", "gpt-5.5", { disableThinking: true }), {+ options: ["none", "low", "medium", "high", "xhigh"],+ defaultValue: "medium",+ });+ assert.equal(selectableReasoningEffort("openai", "gpt-4.1", {}), null);+});++test("picker: hidden for a Custom model while thinking is disabled", async () => {+ const { selectableReasoningEffort } = await import("../../src/services/ai/chatRequestBody.ts");++ assert.equal(selectableReasoningEffort("custom", "grok-4.3", { disableThinking: true }), null);+ assert.deepEqual(selectableReasoningEffort("custom", "grok-4.3", { disableThinking: false }), {+ options: ["none", "minimal", "low", "medium", "high", "xhigh"],+ });+});++test("picker: Custom and OpenRouter offer only what the model family accepts", async () => {+ const { selectableReasoningEffort } = await import("../../src/services/ai/chatRequestBody.ts");+ const on = { disableThinking: false };++ assert.deepEqual(selectableReasoningEffort("custom", "gpt-oss-20b", on).options, [+ "low",+ "medium",+ "high",+ ]);+ assert.deepEqual(selectableReasoningEffort("openrouter", "z-ai/glm-5.3", on).options, [+ "low",+ "high",+ ]);+ assert.equal(selectableReasoningEffort("custom", "qwen3:32b", on), null);+ assert.equal(selectableReasoningEffort("custom", "magistral-small-latest", on), null);+});++test("picker: Custom offers the levels its endpoint's host takes", async () => {+ const { selectableReasoningEffort } = await import("../../src/services/ai/chatRequestBody.ts");+ const on = { disableThinking: false };++ assert.deepEqual(+ selectableReasoningEffort("custom", "grok-4.7", on, "https://api.x.ai/v1").options,+ ["low", "medium", "high", "xhigh"]+ );+ // DeepSeek's API rejects "none" (#1260).+ assert.deepEqual(+ selectableReasoningEffort("custom", "deepseek-chat", on, "https://api.deepseek.com").options,+ ["low", "high"]+ );+});++test("picker: Custom and OpenRouter take a registry model's own levels", async () => {+ const { selectableReasoningEffort } = await import("../../src/services/ai/chatRequestBody.ts");+ const on = { disableThinking: false };++ // No "minimal" for gpt-5.5, and no server default named for an unknown server.+ assert.deepEqual(selectableReasoningEffort("custom", "gpt-5.5", on), {+ options: ["none", "low", "medium", "high", "xhigh"],+ });+ // A streamed Custom turn can't carry "max"; OpenRouter's reasoning object can.+ assert.deepEqual(selectableReasoningEffort("custom", "gpt-6-astra", on).options, [+ "low",+ "medium",+ "high",+ "xhigh",+ ]);+ assert.deepEqual(selectableReasoningEffort("openrouter", "openai/gpt-6-astra", on).options, [+ "low",+ "medium",+ "high",+ "xhigh",+ "max",+ ]);+});++test("picker: the toggle Custom always shows hides the picker, registry model or not", async () => {+ const { chosenReasoningEffort, selectableReasoningEffort } =+ await import("../../src/services/ai/chatRequestBody.ts");++ assert.equal(selectableReasoningEffort("custom", "gpt-5.5", { disableThinking: true }), null);+ assert.equal(+ chosenReasoningEffort("custom", "gpt-5.5", { disableThinking: true, reasoningEffort: "high" }),+ undefined+ );+});++test("a level saved for a cloud provider never reaches a self-hosted server", async () => {+ const { chosenReasoningEffort, selectableReasoningEffort } =+ await import("../../src/services/ai/chatRequestBody.ts");+ const config = { disableThinking: false, reasoningEffort: "high" };++ assert.equal(chosenReasoningEffort("groq", "openai/gpt-oss-120b", config), "high");+ assert.equal(selectableReasoningEffort("lan", "openai/gpt-oss-120b", config), null);+ assert.equal(chosenReasoningEffort("lan", "openai/gpt-oss-120b", config), undefined);+});++test("Responses effort: OpenAI sends the chosen level the model offers", async () => {+ const { responsesReasoningEffort } = await import("../../src/services/ai/chatRequestBody.ts");++ assert.equal(responsesReasoningEffort("gpt-5.5", "openai", CHOSEN("high")), "high");+ assert.equal(responsesReasoningEffort("gpt-6-astra", "openai", CHOSEN("max")), "max");+ // GPT-6 Astra rejects "none", so a stored "none" from another model is dropped.+ assert.equal(responsesReasoningEffort("gpt-6-astra", "openai", CHOSEN("none")), undefined);+});++test("Responses effort: Auto leaves OpenAI at the server default, toggle or not", async () => {+ const { responsesReasoningEffort } = await import("../../src/services/ai/chatRequestBody.ts");++ assert.equal(responsesReasoningEffort("gpt-5.5", "openai", {}), undefined);+ assert.equal(responsesReasoningEffort("gpt-5.5", "openai", { disableThinking: true }), undefined);+ // An id the registry no longer lists: OpenAI hides the toggle, so its+ // default-on value never turns into "none".+ assert.equal(responsesReasoningEffort("gpt-5.4", "openai", { disableThinking: true }), undefined);+ assert.equal(responsesReasoningEffort("o4-mini", "openai", { disableThinking: true }), undefined);+});++test("Responses effort: a Custom endpoint sends any listed level (#791)", async () => {+ const { responsesReasoningEffort } = await import("../../src/services/ai/chatRequestBody.ts");++ assert.equal(responsesReasoningEffort("grok-4.3", "custom", CHOSEN("none")), "none");+ assert.equal(responsesReasoningEffort("grok-4.3", "custom", CHOSEN("max")), undefined);+});++test("Responses effort: the thinking toggle reaches a Custom endpoint's Responses API (#791)", async () => {+ const { responsesReasoningEffort } = await import("../../src/services/ai/chatRequestBody.ts");++ assert.equal(responsesReasoningEffort("grok-4.3", "custom", { disableThinking: true }), "none");+ // A family without an off switch keeps its floor.+ assert.equal(+ responsesReasoningEffort("gpt-oss-120b", "custom", { disableThinking: true }),+ "low"+ );+});++test("Gemini native: a chosen level becomes thinkingLevel; the toggle still wins", async (t) => {+ const { geminiProvider } = await import("../../src/services/ai/inferenceProviders/gemini.ts");+ const requests = [];+ t.mock.method(globalThis, "fetch", async (_url, init) => {+ requests.push(JSON.parse(init.body));+ return Response.json({+ candidates: [{ finishReason: "STOP", content: { parts: [{ text: "Clean text." }] } }],+ });+ });+ const call = (model, config) =>+ geminiProvider.call({+ text: "transcript",+ model,+ agentName: null,+ config,+ ctx: { getApiKey: async () => "test-key", getSystemPrompt: () => "Clean." },+ });++ await call("gemini-3.1-pro-preview", CHOSEN("medium"));+ assert.deepEqual(requests[0].generationConfig.thinkingConfig, {+ thinkingLevel: "medium",+ includeThoughts: false,+ });++ await call("gemini-3-flash-preview", { disableThinking: true, reasoningEffort: "high" });+ assert.deepEqual(requests[1].generationConfig.thinkingConfig, {+ thinkingLevel: "minimal",+ includeThoughts: false,+ });+});++test("Gemini 3.1 Flash Lite: no toggle, so a chosen level beats the minimal floor", async (t) => {+ const { selectableReasoningEffort } = await import("../../src/services/ai/chatRequestBody.ts");+ const { geminiProvider } = await import("../../src/services/ai/inferenceProviders/gemini.ts");+ const requests = [];+ t.mock.method(globalThis, "fetch", async (_url, init) => {+ requests.push(JSON.parse(init.body));+ return Response.json({+ candidates: [{ finishReason: "STOP", content: { parts: [{ text: "Clean text." }] } }],+ });+ });+ const call = (config) =>+ geminiProvider.call({+ text: "transcript",+ model: "gemini-3.1-flash-lite",+ agentName: null,+ config,+ ctx: { getApiKey: async () => "test-key", getSystemPrompt: () => "Clean." },+ });++ // The toggle is hidden for this model and stays at its default, on.+ assert.deepEqual(+ selectableReasoningEffort("gemini", "gemini-3.1-flash-lite", { disableThinking: true }),+ { options: ["minimal", "low", "medium", "high"] }+ );++ await call({ disableThinking: true, reasoningEffort: "low" });+ assert.equal(requests[0].generationConfig.thinkingConfig.thinkingLevel, "low");++ await call({ disableThinking: true });+ assert.equal(requests[1].generationConfig.thinkingConfig.thinkingLevel, "minimal");+});++async function streamRequestBody(t, { provider, model, config, tools, keys = {} }) {+ installBrowserGlobals(t, {+ window: {+ electronAPI: {+ getOpenAIKey: async () => keys.openai ?? "test-key",+ getGroqKey: async () => "test-key",+ getGeminiKey: async () => "test-key",+ getOpenrouterKey: async () => "test-key",+ },+ },+ });+ const vite = await createRendererServer(t, { cachePrefix: `openwhispr-effort-${provider}-` });+ const reasoningService = (await vite.ssrLoadModule("/services/ReasoningService.ts")).default;+ const { usePolicyStore } = await vite.ssrLoadModule("/stores/policyStore.ts");+ usePolicyStore.setState({ status: "unmanaged", appVersion: "1.8.3", policy: null });+ t.after(() => reasoningService.destroy());++ const bodies = [];+ const originalFetch = globalThis.fetch;+ t.after(() => {+ globalThis.fetch = originalFetch;+ });+ globalThis.fetch = async (_url, init) => {+ bodies.push(JSON.parse(init.body));+ return new Response(JSON.stringify({ error: { message: "stop here" } }), {+ status: 400,+ headers: { "content-type": "application/json" },+ });+ };++ const stream = reasoningService.processTextStreamingAI(+ [{ role: "user", content: "hello" }],+ model,+ provider,+ { systemPrompt: "Answer the user.", ...config },+ tools+ );+ await assert.rejects(async () => {+ for await (const _chunk of stream);+ });+ return bodies[0];+}++test("streaming: a Custom endpoint gets reasoning_effort", async (t) => {+ const body = await streamRequestBody(t, {+ provider: "custom",+ model: "grok-4.3",+ config: CHOSEN("low", { baseUrl: "https://api.x.ai/v1", customApiKey: "test-key" }),+ });+ assert.equal(body.reasoning_effort, "low");+});++test("streaming: a Custom level is checked against the endpoint's host", async (t) => {+ const body = await streamRequestBody(t, {+ provider: "custom",+ model: "deepseek-chat",+ // DeepSeek's API rejects "none" (#1260), and a streamed turn has no retry.+ config: CHOSEN("none", { baseUrl: "https://api.deepseek.com", customApiKey: "test-key" }),+ });+ assert.equal(body.reasoning_effort, undefined);+});++test("streaming: a self-hosted turn never sends the level saved for the scope's provider", async (t) => {+ const body = await streamRequestBody(t, {+ provider: "custom",+ model: "grok-4.3",+ config: CHOSEN("low", { lanUrl: "http://127.0.0.1:11434/v1" }),+ tools: {},+ });+ assert.equal(body.reasoning_effort, undefined);+});++test("streaming: native OpenAI sends the effort even for ids the SDK doesn't know", async (t) => {+ const body = await streamRequestBody(t, {+ provider: "openai",+ model: "gpt-6-astra",+ config: CHOSEN("high"),+ });+ assert.deepEqual(body.reasoning, { effort: "high" });+});++test("streaming: OpenRouter gets its reasoning object", async (t) => {+ const body = await streamRequestBody(t, {+ provider: "openrouter",+ model: "openai/gpt-5.5",+ config: CHOSEN("high"),+ });+ assert.deepEqual(body.reasoning, { effort: "high" });+});++test("streaming: Groq gets the chosen level for gpt-oss", async (t) => {+ const body = await streamRequestBody(t, {+ provider: "groq",+ model: "openai/gpt-oss-120b",+ config: CHOSEN("high"),+ });+ assert.equal(body.reasoning_effort, "high");+});++test("streaming: Gemini gets the chosen thinkingLevel", async (t) => {+ const body = await streamRequestBody(t, {+ provider: "gemini",+ model: "gemini-3.1-pro-preview",+ config: CHOSEN("low"),+ });+ assert.deepEqual(body.generationConfig.thinkingConfig, {+ thinkingLevel: "low",+ includeThoughts: false,+ });+});++test("settings: each scope keeps its own effort", async (t) => {+ installBrowserGlobals(t, {+ initialStorage: { _llmScopeKeysMigrated: "1", _dictationAgentSeeded: "1" },+ });+ const vite = await createRendererServer(t, {+ cachePrefix: "openwhispr-effort-settings-",+ resolveAlias: { "@": path.resolve(__dirname, "../../src") },+ });+ await vite.ssrLoadModule("/models/ModelRegistry.ts");+ const s = await vite.ssrLoadModule("/stores/settingsStore.ts");++ s.setResolvedLLMConfig("dictationCleanup", { reasoningEffort: "low" });+ s.setResolvedLLMConfig("chatIntelligence", { reasoningEffort: "high" });+ const state = s.useSettingsStore.getState();++ assert.equal(localStorage.getItem("cleanupReasoningEffort"), "low");+ assert.equal(s.selectResolvedLLMConfig(state, "dictationCleanup").reasoningEffort, "low");+ assert.equal(s.selectResolvedLLMConfig(state, "chatIntelligence").reasoningEffort, "high");+ // Note formatting inherits cleanup's model, not its effort.+ assert.equal(s.selectResolvedLLMConfig(state, "noteFormatting").reasoningEffort, undefined);+});diff --git a/test/stores/actionProcessingChunked.test.js b/test/stores/actionProcessingChunked.test.jsindex fe0d32578..9dbce6ef2 100644--- a/test/stores/actionProcessingChunked.test.js+++ b/test/stores/actionProcessingChunked.test.js@@ -711,12 +711,13 @@ test("a transcript without speaker labels is packed without a prose prefix", asytest("parts never spend their output budget on thinking", async (t) => {const { store, calls, updates } = await loadStore(t, {failFirst: true,- storage: { noteFormattingDisableThinking: "false" },+ storage: { noteFormattingDisableThinking: "false", noteFormattingReasoningEffort: "high" },});run(store, 22, longMaterial(400));await waitForResult(store, updates);assert.equal(updates.length, 1);assert.equal(calls[0].config.disableThinking, false);+ assert.equal(calls[0].config.reasoningEffort, "high");assert.equal(calls.at(-1).config.disableThinking, false);for (const call of calls.slice(1, -1)) assert.equal(call.config.disableThinking, true);});