Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix: preserve explicit model reasoning effort overrides

Seraph-xb9ad8e68a912
diff --git a/apps/desktop/src/components/settings/ModelSelectionPanes.tsx b/apps/desktop/src/components/settings/ModelSelectionPanes.tsx
index 668a838b2..8068d5106 100644
--- a/apps/desktop/src/components/settings/ModelSelectionPanes.tsx
+++ b/apps/desktop/src/components/settings/ModelSelectionPanes.tsx
@@ -36,6 +36,7 @@ import {
import { api } from "../../lib/api";
import { Button, Field, HelpIcon, Input, Tooltip, TooltipButton, cx } from "../ui";
import { IconClose, IconGripVertical, IconHelp, IconPlus, IconRefresh, IconSearch } from "../icons";
+import { ReasoningEffortSelect } from "./ReasoningEffortSelect";
import { SettingsMenuSelect } from "./SettingsMenuSelect";
import { filterChosenModels, hidesAddedBinding } from "./model-chosen-filter";
import {
@@ -935,6 +936,12 @@ export function ModelSelectionPanes({
})}
</div>
</div>
+ {(!apiStyle || apiStyle === "chat_completions" || apiStyle === "opencode_go") ? (
+ <ReasoningEffortSelect
+ value={binding.supportsReasoningEffort}
+ onChange={(supportsReasoningEffort) => updateBinding(binding.id, { supportsReasoningEffort })}
+ />
+ ) : null}
<div className="provider-chosen-capabilities">
<span className="provider-chosen-thinking-label">
{t("settings.modelCapabilities")}
diff --git a/apps/desktop/src/components/settings/ReasoningEffortSelect.tsx b/apps/desktop/src/components/settings/ReasoningEffortSelect.tsx
new file mode 100644
index 000000000..7bd681d0f
--- /dev/null
+++ b/apps/desktop/src/components/settings/ReasoningEffortSelect.tsx
@@ -0,0 +1,29 @@
+import { useTranslation } from "react-i18next";
+import { HelpIcon } from "../ui";
+import { SettingsMenuSelect } from "./SettingsMenuSelect";
+
+export function ReasoningEffortSelect({ value, onChange }: {
+ value?: boolean | null;
+ onChange: (value: boolean | null) => void;
+}) {
+ const { t } = useTranslation();
+ return (
+ <div className="provider-chosen-reasoning-effort">
+ <span className="provider-chosen-thinking-label">
+ {t("settings.reasoningEffortParameter")}
+ <HelpIcon label={t("settings.reasoningEffortParameterHint")} />
+ </span>
+ <SettingsMenuSelect
+ className="provider-chosen-thinking-select"
+ label={t("settings.reasoningEffortParameter")}
+ value={value == null ? "auto" : value ? "send" : "omit"}
+ onChange={(id) => onChange(id === "auto" ? null : id === "send")}
+ options={[
+ { id: "auto", label: t("settings.reasoningEffortAuto") },
+ { id: "send", label: t("settings.reasoningEffortSend") },
+ { id: "omit", label: t("settings.reasoningEffortOmit") },
+ ]}
+ />
+ </div>
+ );
+}
diff --git a/apps/desktop/src/components/settings/provider-copy.ts b/apps/desktop/src/components/settings/provider-copy.ts
index 54b06748b..2bfe14d06 100644
--- a/apps/desktop/src/components/settings/provider-copy.ts
+++ b/apps/desktop/src/components/settings/provider-copy.ts
@@ -43,6 +43,8 @@ export function copyProviderConfiguration(provider: ProviderPublic, name: string
...(model.thinkingProtocol !== undefined
? { thinkingProtocol: model.thinkingProtocol }
: {}),
+ ...(model.supportsReasoningEffort !== undefined
+ ? { supportsReasoningEffort: model.supportsReasoningEffort } : {}),
...(model.supportsImages !== undefined ? { supportsImages: model.supportsImages } : {}),
...(model.supportsDocuments !== undefined ? { supportsDocuments: model.supportsDocuments } : {}),
...(model.availableForSubagents !== undefined ? { availableForSubagents: model.availableForSubagents } : {}),
diff --git a/apps/desktop/src/styles/model-config.css b/apps/desktop/src/styles/model-config.css
index 0817ac04b..2a3dc8ec7 100644
--- a/apps/desktop/src/styles/model-config.css
+++ b/apps/desktop/src/styles/model-config.css
@@ -1166,6 +1166,14 @@
gap: 12px;
}
+.provider-chosen-reasoning-effort {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ justify-content: flex-end;
+ gap: 6px;
+}
+
.provider-chosen-thinking-default,
.provider-chosen-thinking-protocol {
display: flex;
diff --git a/apps/desktop/test/provider-copy.test.mjs b/apps/desktop/test/provider-copy.test.mjs
index 5bf64def2..031ac3992 100644
--- a/apps/desktop/test/provider-copy.test.mjs
+++ b/apps/desktop/test/provider-copy.test.mjs
@@ -60,3 +60,11 @@ test('explicit protocols take precedence over matching endpoint presets', () =>
assert.equal(copy.apiStyle,apiStyle);
}
});
+
+for (const supportsReasoningEffort of [true, false, null]) {
+ test(`copy preserves reasoning effort override ${supportsReasoningEffort}`, () => {
+ const original = source();
+ original.models[0].supportsReasoningEffort = supportsReasoningEffort;
+ assert.equal(copyProviderConfiguration(original, 'Copy').models[0].supportsReasoningEffort, supportsReasoningEffort);
+ });
+}
diff --git a/crates/host-core/src/plugins/providers.rs b/crates/host-core/src/plugins/providers.rs
index 2fa9ed15d..d0fd31d42 100644
--- a/crates/host-core/src/plugins/providers.rs
+++ b/crates/host-core/src/plugins/providers.rs
@@ -180,6 +180,7 @@ pub(crate) fn declared_providers(manifest: &PluginManifest) -> Vec<DeclaredPlugi
.get("thinkingProtocol")
.and_then(Value::as_str)
.map(str::to_string),
+ supports_reasoning_effort: None,
supports_images: model
.get("supportsImages")
.and_then(Value::as_bool),
diff --git a/crates/host-core/src/providers/catalog.rs b/crates/host-core/src/providers/catalog.rs
index 76472dfd6..0f2de9869 100644
--- a/crates/host-core/src/providers/catalog.rs
+++ b/crates/host-core/src/providers/catalog.rs
@@ -77,6 +77,7 @@ pub(crate) fn normalize_model_bindings(bindings: &[ModelBinding]) -> Vec<ModelBi
thinking_levels,
default_thinking_level,
thinking_protocol,
+ supports_reasoning_effort: binding.supports_reasoning_effort,
supports_images: binding.supports_images,
supports_documents: binding.supports_documents,
available_for_subagents: binding.available_for_subagents,
@@ -100,6 +101,7 @@ fn legacy_model_binding(model_id: Option<String>) -> Vec<ModelBinding> {
thinking_levels: Vec::new(),
default_thinking_level: None,
thinking_protocol: None,
+ supports_reasoning_effort: None,
supports_images: None,
supports_documents: None,
available_for_subagents: None,
@@ -486,6 +488,7 @@ mod tests {
thinking_levels: Vec::new(),
default_thinking_level: None,
thinking_protocol: None,
+ supports_reasoning_effort: None,
supports_images: None,
supports_documents: None,
available_for_subagents: None,
diff --git a/crates/host-core/src/providers/model.rs b/crates/host-core/src/providers/model.rs
index 40f590012..1af5a54c6 100644
--- a/crates/host-core/src/providers/model.rs
+++ b/crates/host-core/src/providers/model.rs
@@ -155,6 +155,9 @@ pub struct ModelBinding {
/// Provider request protocol used when thinking is enabled.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub thinking_protocol: Option<String>,
+ /// Explicit Chat Completions reasoning_effort override; None keeps compatibility defaults.
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ pub supports_reasoning_effort: Option<bool>,
/// Attachment capability overrides. `None` follows the published catalog
/// capability, so a models.dev correction still reaches a saved binding.
#[serde(default, skip_serializing_if = "Option::is_none")]
diff --git a/crates/host-core/src/providers/repository.rs b/crates/host-core/src/providers/repository.rs
index 7dc2ed4b3..027648787 100644
--- a/crates/host-core/src/providers/repository.rs
+++ b/crates/host-core/src/providers/repository.rs
@@ -103,6 +103,7 @@ fn hydrate_dynamic_plugin_models(db: &Database, provider: &mut ProviderPublic) -
thinking_levels: Vec::new(),
default_thinking_level: None,
thinking_protocol: None,
+ supports_reasoning_effort: None,
supports_images: model
.capabilities
.iter()
diff --git a/crates/host-core/src/providers/tests.rs b/crates/host-core/src/providers/tests.rs
index 6e953e1fd..497be4896 100644
--- a/crates/host-core/src/providers/tests.rs
+++ b/crates/host-core/src/providers/tests.rs
@@ -249,6 +249,7 @@ fn model_bindings_roundtrip_and_legacy_model_migrates_on_read() {
thinking_levels: vec!["high".into(), "medium".into()],
default_thinking_level: Some("medium".into()),
thinking_protocol: Some("adaptive".into()),
+ supports_reasoning_effort: None,
supports_images: Some(true),
supports_documents: None,
available_for_subagents: Some(true),
@@ -264,6 +265,7 @@ fn model_bindings_roundtrip_and_legacy_model_migrates_on_read() {
thinking_levels: vec![],
default_thinking_level: None,
thinking_protocol: None,
+ supports_reasoning_effort: None,
supports_images: None,
supports_documents: Some(false),
available_for_subagents: None,
@@ -373,6 +375,7 @@ fn binding_with_alias(id: &str, alias: Option<&str>) -> ModelBinding {
thinking_levels: Vec::new(),
default_thinking_level: None,
thinking_protocol: None,
+ supports_reasoning_effort: None,
supports_images: None,
supports_documents: None,
available_for_subagents: None,
@@ -1556,6 +1559,7 @@ fn binding_with_limits(id: &str, context_window: u32, max_tokens: u32) -> ModelB
thinking_levels: Vec::new(),
default_thinking_level: None,
thinking_protocol: None,
+ supports_reasoning_effort: None,
supports_images: None,
supports_documents: None,
available_for_subagents: None,
@@ -1978,3 +1982,40 @@ fn sync_payloads_keep_only_storable_headers() {
let raw = BTreeMap::from([("x-cjk".to_string(), "星".to_string())]);
assert!(storable_headers(&raw).is_empty());
}
+
+#[test]
+fn reasoning_effort_override_survives_provider_create_update_and_read() {
+ let (_dir, db, secrets) = test_context();
+ let binding = serde_json::json!({
+ "id": "deepseek-v4.1-flash", "thinkingLevels": ["off", "high"],
+ "supportsReasoningEffort": true
+ });
+ let input: ProviderCreateInput = serde_json::from_value(serde_json::json!({
+ "name": "Reasoning gateway", "baseUrl": "https://gateway.example/v1",
+ "authKind": "none", "apiStyle": "chat_completions", "models": [binding]
+ }))
+ .unwrap();
+ let provider = create_provider(&db, &secrets, input).unwrap();
+ assert_eq!(
+ serde_json::to_value(&provider).unwrap()["models"][0]["supportsReasoningEffort"],
+ true
+ );
+ for value in [
+ serde_json::json!(false),
+ serde_json::Value::Null,
+ serde_json::json!(true),
+ ] {
+ let mut model = binding.clone();
+ model["supportsReasoningEffort"] = value.clone();
+ let input: ProviderUpdateInput = serde_json::from_value(serde_json::json!({
+ "id": provider.id, "models": [model]
+ }))
+ .unwrap();
+ update_provider(&db, &secrets, input).unwrap();
+ let loaded = get_provider(&db, &secrets, &provider.id).unwrap().unwrap();
+ assert_eq!(
+ serde_json::to_value(loaded).unwrap()["models"][0]["supportsReasoningEffort"],
+ value
+ );
+ }
+}
diff --git a/docs/adr/README.md b/docs/adr/README.md
index a3cfcc0ff..4452e1b44 100644
--- a/docs/adr/README.md
+++ b/docs/adr/README.md
@@ -387,3 +387,5 @@ Each ADR includes:
| local-agent-remote-workspace-tools | [Local Agent and model requests for remote workspaces](local-agent-remote-workspace-tools.md) | Accepted for implementation |
| 0332 | [macOS keeps its translucent window surface with an opaque opt-out](0332-macos-opaque-window-surface.md) | Accepted (D665, amended by D666 and D667; supersedes the macOS vibrancy window backing from D348; issue #1064) |
| gen-ui-inline-visualization | [Inline generative UI visualizations](gen-ui-inline-visualization.md) | Accepted (D671) |
+
+| model-reasoning-effort-override | [Model reasoning effort override](model-reasoning-effort-override.md) | Proposed |
diff --git a/docs/adr/model-reasoning-effort-override.md b/docs/adr/model-reasoning-effort-override.md
new file mode 100644
index 000000000..865dfff10
--- /dev/null
+++ b/docs/adr/model-reasoning-effort-override.md
@@ -0,0 +1,33 @@
+# ADR: Model reasoning effort override
+
+- Status: Proposed
+- Date: 2026-10-23
+- Related: issue #1821, issue #1701
+
+## Context
+
+DeepSeek-family Chat Completions compatibility disables `reasoning_effort`
+for endpoints that reject that field. Model-name detection also covers custom
+relays that do support it, so choosing High can silently omit the parameter.
+Changing the automatic default would regress the endpoints protected by #1701.
+
+## Decision
+
+Add optional `supportsReasoningEffort: boolean | null` to the persisted model
+binding. Missing/null retains automatic compatibility; true/false explicitly
+allows/disallows the parameter. Keep this provenance separate from catalog
+compatibility and apply it last, only when building a Chat Completions model.
+The setting does not turn reasoning on or override the selected thinking level.
+
+Expose Auto / Send / Do not send in the existing per-model settings. Host
+normalization, configuration copying and synchronization preserve the value.
+Other APIs hide the setting and ignore it during request construction.
+
+## Consequences
+
+Legacy JSON needs no migration: an absent field retains its prior behavior.
+Clearing a choice restores automatic compatibility. A user enabling Send is
+responsible for selecting a gateway that accepts the parameter; provider errors
+remain visible. No retry, silent protocol change or compatibility fallback is
+introduced. The alternative of globally re-enabling the field is rejected
+because it would undo the existing DeepSeek protection.
diff --git a/docs/spec/03-runtime/02-agent-runtime.md b/docs/spec/03-runtime/02-agent-runtime.md
index fb428448f..428577b23 100644
--- a/docs/spec/03-runtime/02-agent-runtime.md
+++ b/docs/spec/03-runtime/02-agent-runtime.md
@@ -782,6 +782,12 @@ criterion-by-criterion report of what was met and the evidence observed.
enables or disables image transport for the configured binding. Unknown or
custom ids remain conservative text/path models unless their binding
explicitly enables image input.
+- A model binding's optional `supportsReasoningEffort` controls the Chat
+ Completions `reasoning_effort` parameter only. An absent or `null` value keeps
+ existing catalog/provider compatibility; an explicit boolean takes precedence
+ over automatic compatibility detection, including DeepSeek-family defaults.
+ This does not enable reasoning, select a level, or change Responses/Anthropic
+ request serialization. Published compatibility alone is not an explicit opt-in.
- The effective level is passed to the pi `Agent`; provider-specific request
serialization remains pi-ai's responsibility.
- Pi `thinking` blocks become `UiMessage.thinking` and
diff --git a/docs/spec/04-ux/06-settings-ia.md b/docs/spec/04-ux/06-settings-ia.md
index e69f11c08..bd6cd6271 100644
--- a/docs/spec/04-ux/06-settings-ia.md
+++ b/docs/spec/04-ux/06-settings-ia.md
@@ -519,6 +519,11 @@ a usage tab.
outside settings container dismisses it before the trigger can become
detached. Search results keep a dedicated no-match state instead of
reusing the search placeholder.
+ - Chat Completions model settings include a reasoning effort parameter menu:
+ **Auto**, **Send**, and **Do not send**. Auto restores compatibility defaults;
+ the other choices persist an explicit per-model `supportsReasoningEffort`
+ boolean. The selection survives save/reopen, copying, and configuration sync.
+ Other API formats hide this control without deleting the saved preference.
- the context-window field states its provenance: while the number still
follows the published models.dev limit, a faint hint under the input says so
(`settings.contextWindowCatalogHint`), and the first edit — the preset
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index e5ba6c70b..79d47e03f 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -18699,3 +18699,21 @@ host-created files. The full app's file-preview viewer is covered separately.
Rust visualization RPC/lifecycle/fork tests
cover authorization, deletion safety, Windows path spelling, and relocation.
- **Status**: Automated without a paid provider or a user's running instance.
+
+#### E2E-PROVIDER-reasoning-effort-override: Preserve an explicit gateway reasoning parameter
+
+- **Setup:** A custom Chat Completions provider with a DeepSeek-family model;
+ start with a legacy binding that omits `supportsReasoningEffort`.
+- **Steps:** In English, Chinese and German at 850/1000/1400px widths, open model settings, confirm Auto, select
+ Send, save and reopen; repeat for Do not send and Auto. Switch to Responses
+ and Anthropic and confirm the Completions-only control is hidden.
+- **Expected:** Each saved binding retains true, false, or null respectively.
+ With High selected, the real Completions adapter sends `reasoning_effort: high`
+ only when enabled; Auto keeps the existing DeepSeek compatibility default.
+ Responses continues using its own reasoning contract. Provider creation,
+ update/read, copying, and sync preserve the explicit override.
+- **Automation:** `node scripts/e2e-provider-api-style.mjs --reasoning-effort` exercises real
+ React/Chromium controls and captures the Host API payload (the IPC boundary is
+ stubbed). Rust provider tests independently verify real SQLite persistence;
+ `provider-reasoning-effort.test.ts` captures requests from the real pi-ai
+ adapter with fixture SSE responses. No live gateway credentials are required.
diff --git a/docs/zh-CN/spec/03-runtime/02-agent-runtime.md b/docs/zh-CN/spec/03-runtime/02-agent-runtime.md
index c04d2913c..4811a85ba 100644
--- a/docs/zh-CN/spec/03-runtime/02-agent-runtime.md
+++ b/docs/zh-CN/spec/03-runtime/02-agent-runtime.md
@@ -585,6 +585,10 @@ Goal 批准所承诺的内容与 Plan 批准所承诺的内容完全相同:`mo
- 视觉支持由同一条 Pi catalog 记录解析:只有 `input.includes("image")` 才启用
图片传输。未知/自定义模型 id 保持为保守的 text/path 模型,即使发现到的元数据
声称支持 `vision`。
+- 模型绑定的可选 `supportsReasoningEffort` 仅控制 Chat Completions 的
+ `reasoning_effort` 参数。缺省或 `null` 保留目录及供应商兼容默认值;显式布尔值
+ 优先于自动兼容识别,包括 DeepSeek 系列默认值。它不启用推理、不选择思考档位,
+ 也不改变 Responses 或 Anthropic 的请求序列化。目录兼容元数据不等于用户显式开启。
- 有效级别会传给 pi `Agent`;特定于提供商的请求
序列化仍然是 pi-ai 的责任。
- Pi `thinking` 块变为 `UiMessage.thinking` 并且
diff --git a/docs/zh-CN/spec/04-ux/06-settings-ia.md b/docs/zh-CN/spec/04-ux/06-settings-ia.md
index dd6e7377b..ba4d05a3c 100644
--- a/docs/zh-CN/spec/04-ux/06-settings-ia.md
+++ b/docs/zh-CN/spec/04-ux/06-settings-ia.md
@@ -211,6 +211,10 @@ Token 用量**不是设置目的地**(D335 / ADR 0173)。已完成回合历
行内以统一的紧凑格式显示模型 ID、来源、能力与上限(如 `1.05M · 128K`),
相邻窗口不会被舍入成同一个字符串;
展开区是紧凑表单:别名说明放在输入框 title 上,数字框去掉原生步进按钮,思考档铺满一行且默认档与标签同行,附件与委派勾选同一行。
+ Chat Completions 的模型设置提供思考强度参数菜单:“自动”“发送”“不发送”。
+ 自动恢复兼容默认值,其他选项保存模型级 `supportsReasoningEffort` 布尔值。
+ 保存后重新打开、复制配置和配置同步均保留选择;其他 API 格式隐藏该控件,
+ 但不删除已保存的偏好。
上下文窗口字段会说明自己的来源:数值仍跟随 models.dev 发布上限时,输入框下方显示
一行淡色提示(`settings.contextWindowCatalogHint`);用户第一次改动(预设档位或
数字输入)即把该值固定为用户自己的值并移除提示。被用户固定的值不会被目录刷新
diff --git a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
index 102c77a49..45af7f685 100644
--- a/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/zh-CN/spec/06-delivery/04-e2e-test-plan.md
@@ -9941,3 +9941,21 @@ host-created files. The full app's file-preview viewer is covered separately.
- **关联规格**:`04-ux/01-ui-ia.md` §3.2、`04-ux/06-settings-ia.md`(常规 → 侧边栏卡片)。
- **验收**:项目折叠时仍能回答“这里是否有正在运行的工作”,且两种提示可从持久化设置独立控制。
- **状态**:草稿。现有 `apps/desktop/test/sidebar-project-runs.test.mjs` 覆盖数量分类、总开关与子开关门控、两种渲染入口,以及主题令牌和减少动态效果保证;它不覆盖设置 API 缺省值规范化或完整交互,相关场景仍需在可用环境手动验证。
+
+#### E2E-PROVIDER-reasoning-effort-override: Preserve an explicit gateway reasoning parameter
+
+- **Setup:** A custom Chat Completions provider with a DeepSeek-family model;
+ start with a legacy binding that omits `supportsReasoningEffort`.
+- **Steps:** In English, Chinese and German at 850/1000/1400px widths, open model settings, confirm Auto, select
+ Send, save and reopen; repeat for Do not send and Auto. Switch to Responses
+ and Anthropic and confirm the Completions-only control is hidden.
+- **Expected:** Each saved binding retains true, false, or null respectively.
+ With High selected, the real Completions adapter sends `reasoning_effort: high`
+ only when enabled; Auto keeps the existing DeepSeek compatibility default.
+ Responses continues using its own reasoning contract. Provider creation,
+ update/read, copying, and sync preserve the explicit override.
+- **Automation:** `node scripts/e2e-provider-api-style.mjs --reasoning-effort` exercises real
+ React/Chromium controls and captures the Host API payload (the IPC boundary is
+ stubbed). Rust provider tests independently verify real SQLite persistence;
+ `provider-reasoning-effort.test.ts` captures requests from the real pi-ai
+ adapter with fixture SSE responses. No live gateway credentials are required.
diff --git a/packages/agent-runtime/src/model-capabilities.ts b/packages/agent-runtime/src/model-capabilities.ts
index 43e54643c..6a6496b72 100644
--- a/packages/agent-runtime/src/model-capabilities.ts
+++ b/packages/agent-runtime/src/model-capabilities.ts
@@ -98,6 +98,7 @@ export function modelConfigWithBinding(
| "maxTokens"
| "thinkingLevels"
| "thinkingProtocol"
+ | "supportsReasoningEffort"
| "supportsImages"
| "supportsDocuments"
| "nativeWebSearch"
@@ -178,6 +179,7 @@ export function modelConfigWithBinding(
? model.reasoning || enabledThinkingLevels.some((level) => level !== "off")
: enabledThinkingLevels.some((level) => level !== "off"),
supportedThinkingLevels: enabledThinkingLevels,
+ supportsReasoningEffort: binding.supportsReasoningEffort,
...(binding.thinkingProtocol
? { thinkingProtocol: binding.thinkingProtocol }
: {}),
diff --git a/packages/agent-runtime/src/provider-binding.ts b/packages/agent-runtime/src/provider-binding.ts
index a7ef03a38..a700045b3 100644
--- a/packages/agent-runtime/src/provider-binding.ts
+++ b/packages/agent-runtime/src/provider-binding.ts
@@ -356,7 +356,7 @@ export function buildProviderModel(
const binding = apiBindingForProviderModel(provider);
const catalog = provider.modelConfig;
const catalogModel = catalog
- ? (({ source: _source, transcriptBinding: _transcriptBinding, nativeCost, ...model }) => ({
+ ? (({ source: _source, transcriptBinding: _transcriptBinding, supportsReasoningEffort: _supportsReasoningEffort, nativeCost, ...model }) => ({
...model,
...(nativeCost ? { cost: nativeCost } : {}),
}))(catalog)
@@ -419,6 +419,10 @@ export function buildProviderModel(
...(thinkingProtocolCompat ?? {}),
...(zhipuCompat ?? {}),
...(deepseekCompat ?? {}),
+ // Only an explicit saved binding may override endpoint compatibility.
+ ...(typeof catalog?.supportsReasoningEffort === "boolean"
+ ? { supportsReasoningEffort: catalog.supportsReasoningEffort }
+ : {}),
supportsDeveloperRole: catalogModel.compat?.supportsDeveloperRole === true,
}
: binding.api === "anthropic-messages" &&
diff --git a/packages/agent-runtime/src/provider-reasoning-effort.test.ts b/packages/agent-runtime/src/provider-reasoning-effort.test.ts
new file mode 100644
index 000000000..0a107f667
--- /dev/null
+++ b/packages/agent-runtime/src/provider-reasoning-effort.test.ts
@@ -0,0 +1,94 @@
+import { describe, expect, it } from "vitest";
+import { genericModelConfig, modelConfigWithBinding } from "./model-capabilities.js";
+import { buildProviderModel, createProviderModels, type RuntimeProviderConfig } from "./provider-binding.js";
+
+function providerFor(modelId: string, supportsReasoningEffort?: boolean | null): RuntimeProviderConfig {
+ return {
+ id: "custom-gateway",
+ name: "Custom gateway",
+ baseUrl: "https://gateway.example/v1",
+ authKind: "api_key_and_base_url",
+ apiKey: "fixture-key",
+ apiStyle: "chat_completions",
+ modelId,
+ supportsReasoning: true,
+ supportedThinkingLevels: ["off", "high"],
+ modelConfig: modelConfigWithBinding(genericModelConfig(modelId), {
+ contextWindow: 128_000,
+ maxTokens: 8192,
+ thinkingLevels: ["off", "high"],
+ supportsReasoningEffort,
+ }),
+ };
+}
+
+describe("per-model Chat Completions reasoning effort override", () => {
+ it.each([
+ ["deepseek-v4.1-flash", undefined, undefined],
+ ["deepseek-v4.1-flash", null, undefined],
+ ["deepseek-v4.1-flash", true, "high"],
+ ["deepseek-v4.1-flash", false, undefined],
+ ["custom-reasoner", undefined, "high"],
+ ["custom-reasoner", null, "high"],
+ ["custom-reasoner", true, "high"],
+ ["custom-reasoner", false, undefined],
+ ] as const)("%s with override %s sends effort %s", async (modelId, override, expected) => {
+ const provider = providerFor(modelId, override);
+ const model = buildProviderModel(provider);
+ const bodies: Record<string, unknown>[] = [];
+ const result = await createProviderModels(provider, model).streamSimple(model, {
+ messages: [{ role: "user", content: "hello", timestamp: 0 }],
+ }, {
+ reasoning: "high",
+ fetch: async (input, init) => {
+ bodies.push(await new Request(input, init).json() as Record<string, unknown>);
+ const chunk = {
+ id: "fixture", object: "chat.completion.chunk", created: 0, model: modelId,
+ choices: [{ index: 0, delta: { role: "assistant", content: "OK" }, finish_reason: "stop" }],
+ };
+ return new Response(`data: ${JSON.stringify(chunk)}\n\ndata: [DONE]\n\n`, {
+ headers: { "content-type": "text/event-stream" },
+ });
+ },
+ }).result();
+ expect(result.stopReason).toBe("stop");
+ expect(result.content).toEqual([{ type: "text", text: "OK" }]);
+ expect(bodies).toHaveLength(1);
+ expect(bodies[0].reasoning_effort).toBe(expected);
+ });
+
+ it.each([true, false, null])("does not apply override %s to Responses", async (override) => {
+ const provider = { ...providerFor("deepseek-v4.1-flash", override), apiStyle: "responses" };
+ const model = buildProviderModel(provider);
+ expect(model.api).toBe("openai-responses");
+ expect(model.compat ?? {}).not.toHaveProperty("supportsReasoningEffort");
+ const bodies: Record<string, unknown>[] = [];
+ const result = await createProviderModels(provider, model).streamSimple(model, {
+ messages: [{ role: "user", content: "hello", timestamp: 0 }],
+ }, {
+ reasoning: "high",
+ fetch: async (input, init) => {
+ bodies.push(await new Request(input, init).json() as Record<string, unknown>);
+ const completed = { type: "response.completed", response: { id: "fixture", status: "completed", output: [] } };
+ return new Response(`event: response.completed\ndata: ${JSON.stringify(completed)}\n\n`, {
+ headers: { "content-type": "text/event-stream" },
+ });
+ },
+ }).result();
+ expect(result.stopReason).toBe("stop");
+ expect(bodies).toHaveLength(1);
+ expect(bodies[0].reasoning).toMatchObject({ effort: "high" });
+ expect(bodies[0]).not.toHaveProperty("reasoning_effort");
+ });
+
+ it.each([undefined, null, false, true])("keeps official DeepSeek auto protection with override %s", (override) => {
+ const provider = { ...providerFor("deepseek-v4.1-flash", override), vendorKey: "deepseek", baseUrl: "https://api.deepseek.com" };
+ expect(buildProviderModel(provider).compat).toMatchObject({ supportsReasoningEffort: override === true });
+ });
+
+ it("does not mistake catalog compatibility for an explicit saved override", () => {
+ const provider = providerFor("deepseek-v4.1-flash");
+ provider.modelConfig = { ...provider.modelConfig!, compat: { supportsReasoningEffort: true } };
+ expect(buildProviderModel(provider).compat).toMatchObject({ supportsReasoningEffort: false });
+ });
+});
diff --git a/packages/agent-runtime/src/thinking-level.ts b/packages/agent-runtime/src/thinking-level.ts
index f386bbe80..7c19d6c6c 100644
--- a/packages/agent-runtime/src/thinking-level.ts
+++ b/packages/agent-runtime/src/thinking-level.ts
@@ -36,6 +36,8 @@ export type ModelConfig = {
reasoning: boolean;
reasoningOptions?: ModelReasoningOption[];
thinkingProtocol?: ThinkingProtocol;
+ /** Explicit binding override, separate from published adapter compatibility. */
+ supportsReasoningEffort?: boolean | null;
supportedThinkingLevels?: readonly ThinkingLevel[];
thinkingLevelMap?: Partial<Record<ThinkingLevel, string | null>>;
toolCall?: boolean;
diff --git a/packages/i18n/src/locales/de/index.ts b/packages/i18n/src/locales/de/index.ts
index 6c387977e..c1844caf9 100644
--- a/packages/i18n/src/locales/de/index.ts
+++ b/packages/i18n/src/locales/de/index.ts
@@ -1736,6 +1736,11 @@ sklm: {
"maxOutput": "Maximale Ausgabe",
"supportedThinkingLevels": "Denkebenen",
"defaultThinkingLevel": "Standard-Denkebene",
+ "reasoningEffortParameter": "Parameter für Denkaufwand",
+ "reasoningEffortParameterHint": "Nur Chat Completions. reasoning_effort senden, wenn Ihr Gateway es unterstützt. Auto behält die Kompatibilitätsvorgaben des Anbieters bei.",
+ "reasoningEffortAuto": "Auto",
+ "reasoningEffortSend": "Senden",
+ "reasoningEffortOmit": "Nicht senden",
"thinkingProtocol": "Denkprotokoll",
"thinkingProtocolLegacy": "Standard",
"thinkingProtocolAdaptive": "Adaptiv",
diff --git a/packages/i18n/src/locales/en/index.ts b/packages/i18n/src/locales/en/index.ts
index fd0f834f4..3ecab7a64 100644
--- a/packages/i18n/src/locales/en/index.ts
+++ b/packages/i18n/src/locales/en/index.ts
@@ -1756,6 +1756,11 @@ sklm: {
maxOutput: "Max output",
supportedThinkingLevels: "Thinking levels",
defaultThinkingLevel: "Default thinking level",
+ reasoningEffortParameter: "Reasoning effort parameter",
+ reasoningEffortParameterHint: "Chat Completions only. Send reasoning_effort if your gateway supports it. Auto keeps provider compatibility defaults.",
+ reasoningEffortAuto: "Auto",
+ reasoningEffortSend: "Send",
+ reasoningEffortOmit: "Do not send",
thinkingProtocol: "Thinking protocol",
thinkingProtocolLegacy: "Standard",
thinkingProtocolAdaptive: "Adaptive",
diff --git a/packages/i18n/src/locales/es/index.ts b/packages/i18n/src/locales/es/index.ts
index ef414a2a8..388a60a12 100644
--- a/packages/i18n/src/locales/es/index.ts
+++ b/packages/i18n/src/locales/es/index.ts
@@ -1736,6 +1736,11 @@ sklm: {
"maxOutput": "Salida máxima",
"supportedThinkingLevels": "Niveles de pensamiento",
"defaultThinkingLevel": "Nivel de pensamiento predeterminado",
+ "reasoningEffortParameter": "Parámetro de esfuerzo de razonamiento",
+ "reasoningEffortParameterHint": "Solo Chat Completions. Envía reasoning_effort si tu pasarela lo admite. Auto conserva los valores de compatibilidad del proveedor.",
+ "reasoningEffortAuto": "Auto",
+ "reasoningEffortSend": "Enviar",
+ "reasoningEffortOmit": "No enviar",
"thinkingProtocol": "Protocolo de pensamiento",
"thinkingProtocolLegacy": "Estándar",
"thinkingProtocolAdaptive": "Adaptativo",
diff --git a/packages/i18n/src/locales/fr/index.ts b/packages/i18n/src/locales/fr/index.ts
index 411597eb8..dacb6a77c 100644
--- a/packages/i18n/src/locales/fr/index.ts
+++ b/packages/i18n/src/locales/fr/index.ts
@@ -1736,6 +1736,11 @@ sklm: {
"maxOutput": "Sortie maximale",
"supportedThinkingLevels": "Niveaux de réflexion",
"defaultThinkingLevel": "Niveau de réflexion par défaut",
+ "reasoningEffortParameter": "Paramètre d’effort de raisonnement",
+ "reasoningEffortParameterHint": "Chat Completions uniquement. Envoyez reasoning_effort si votre passerelle le prend en charge. Auto conserve les valeurs de compatibilité du fournisseur.",
+ "reasoningEffortAuto": "Auto",
+ "reasoningEffortSend": "Envoyer",
+ "reasoningEffortOmit": "Ne pas envoyer",
"thinkingProtocol": "Protocole de réflexion",
"thinkingProtocolLegacy": "Standard",
"thinkingProtocolAdaptive": "Adaptatif",
diff --git a/packages/i18n/src/locales/ko/index.ts b/packages/i18n/src/locales/ko/index.ts
index 45c2ad1c4..f64466b61 100644
--- a/packages/i18n/src/locales/ko/index.ts
+++ b/packages/i18n/src/locales/ko/index.ts
@@ -1752,6 +1752,11 @@ sklm: {
maxOutput: "최대 출력",
supportedThinkingLevels: "생각 수준",
defaultThinkingLevel: "기본 생각 수준",
+ reasoningEffortParameter: "추론 강도 매개변수",
+ reasoningEffortParameterHint: "Chat Completions에만 적용됩니다. 게이트웨이가 지원하면 reasoning_effort를 전송하세요. 자동은 공급자 호환성 기본값을 유지합니다.",
+ reasoningEffortAuto: "자동",
+ reasoningEffortSend: "전송",
+ reasoningEffortOmit: "전송 안 함",
thinkingProtocol: "사고 프로토콜",
thinkingProtocolLegacy: "표준",
thinkingProtocolAdaptive: "적응형",
diff --git a/packages/i18n/src/locales/pt-BR/index.ts b/packages/i18n/src/locales/pt-BR/index.ts
index 9f58764ef..86fa6fa98 100644
--- a/packages/i18n/src/locales/pt-BR/index.ts
+++ b/packages/i18n/src/locales/pt-BR/index.ts
@@ -1706,6 +1706,11 @@ export const ptBR = {
maxOutput: "Saída máxima",
supportedThinkingLevels: "Níveis de raciocínio",
defaultThinkingLevel: "Nível de raciocínio padrão",
+ reasoningEffortParameter: "Parâmetro de esforço de raciocínio",
+ reasoningEffortParameterHint: "Somente Chat Completions. Envie reasoning_effort se o gateway oferecer suporte. Auto mantém os padrões de compatibilidade do provedor.",
+ reasoningEffortAuto: "Auto",
+ reasoningEffortSend: "Enviar",
+ reasoningEffortOmit: "Não enviar",
thinkingProtocol: "Protocolo de pensamento",
thinkingProtocolLegacy: "Padrão",
thinkingProtocolAdaptive: "Adaptativo",
diff --git a/packages/i18n/src/locales/tr/index.ts b/packages/i18n/src/locales/tr/index.ts
index f95093781..fe3ec06c5 100644
--- a/packages/i18n/src/locales/tr/index.ts
+++ b/packages/i18n/src/locales/tr/index.ts
@@ -1746,6 +1746,11 @@ sklm: {
maxOutput: "En fazla çıktı",
supportedThinkingLevels: "Düşünme düzeyleri",
defaultThinkingLevel: "Varsayılan düşünme düzeyi",
+ reasoningEffortParameter: "Akıl yürütme çabası parametresi",
+ reasoningEffortParameterHint: "Yalnızca Chat Completions. Ağ geçidiniz destekliyorsa reasoning_effort gönderin. Otomatik, sağlayıcı uyumluluk varsayılanlarını korur.",
+ reasoningEffortAuto: "Otomatik",
+ reasoningEffortSend: "Gönder",
+ reasoningEffortOmit: "Gönderme",
thinkingProtocol: "Düşünme protokolü",
thinkingProtocolLegacy: "Standart",
thinkingProtocolAdaptive: "Uyarlanabilir",
diff --git a/packages/i18n/src/locales/zh-CN/index.ts b/packages/i18n/src/locales/zh-CN/index.ts
index 8aa583c1a..ae859edb4 100644
--- a/packages/i18n/src/locales/zh-CN/index.ts
+++ b/packages/i18n/src/locales/zh-CN/index.ts
@@ -1731,6 +1731,11 @@ sklm: {
maxOutput: "最大输出",
supportedThinkingLevels: "思考等级",
defaultThinkingLevel: "默认思考等级",
+ reasoningEffortParameter: "思考强度参数",
+ reasoningEffortParameterHint: "仅适用于 Chat Completions。网关支持时可选择发送 reasoning_effort;自动模式保留供应商兼容默认值。",
+ reasoningEffortAuto: "自动",
+ reasoningEffortSend: "发送",
+ reasoningEffortOmit: "不发送",
thinkingProtocol: "思考协议",
thinkingProtocolLegacy: "标准",
thinkingProtocolAdaptive: "自适应",
diff --git a/packages/i18n/src/locales/zh-TW/index.ts b/packages/i18n/src/locales/zh-TW/index.ts
index 4f427611b..9bef326f9 100644
--- a/packages/i18n/src/locales/zh-TW/index.ts
+++ b/packages/i18n/src/locales/zh-TW/index.ts
@@ -1731,6 +1731,11 @@ sklm: {
maxOutput: "最大輸出",
supportedThinkingLevels: "思考等級",
defaultThinkingLevel: "預設思考等級",
+ reasoningEffortParameter: "思考強度參數",
+ reasoningEffortParameterHint: "僅適用於 Chat Completions。閘道支援時可選擇傳送 reasoning_effort;自動模式保留供應商相容預設值。",
+ reasoningEffortAuto: "自動",
+ reasoningEffortSend: "傳送",
+ reasoningEffortOmit: "不傳送",
thinkingProtocol: "思考協定",
thinkingProtocolLegacy: "標準",
thinkingProtocolAdaptive: "自適應",
diff --git a/packages/shared/src/provider-sync.test.ts b/packages/shared/src/provider-sync.test.ts
index 563d58b4a..16919ab82 100644
--- a/packages/shared/src/provider-sync.test.ts
+++ b/packages/shared/src/provider-sync.test.ts
@@ -13,6 +13,11 @@ function payload() {
const provider = { ...payload().providers[0]!.input, id: "local-1", enabled: true, hasSecret: true, supportsReasoning: true, supportedThinkingLevels: ["off", "high"], createdAt: "1", updatedAt: "1" } as ProviderPublic;
describe("provider sync boundary", () => {
+ it.each([true, false, null])("preserves reasoning effort override %s", (supportsReasoningEffort) => {
+ const input = payload();
+ Object.assign(input.providers[0]!.input.models[0]!, { supportsReasoningEffort });
+ expect(parseProviderImportPayload(input)).toEqual(input);
+ });
it("preserves current model settings and meaningful zero values", () => {
const input = payload();
expect(parseProviderImportPayload(input)).toEqual(input);
@@ -42,7 +47,8 @@ describe("provider sync boundary", () => {
{ supportedThinkingLevels: ["secret-level"] }, { temperature: Number.NaN },
{ models: [{ ...model, contextWindow: -1 }] }, { models: [{ ...model, extra: "fixture-key" }] },
{ models: [{ ...model, thinkingLevels: ["not-a-level"] }] }, { models: [{ ...model, defaultThinkingLevel: "low" }] },
- { models: [{ ...model, supportsDocuments: "yes" }] }, { defaultModelId: "missing" },
+ { models: [{ ...model, supportsDocuments: "yes" }] },
+ { models: [{ ...model, supportsReasoningEffort: "true" }] }, { defaultModelId: "missing" },
])("rejects malformed inputs without echoing diagnostics: %j", (patch) => {
const value = payload();
Object.assign(value.providers[0]!.input, patch);
diff --git a/packages/shared/src/provider-sync.ts b/packages/shared/src/provider-sync.ts
index 60a9fb1ea..7d280eae3 100644
--- a/packages/shared/src/provider-sync.ts
+++ b/packages/shared/src/provider-sync.ts
@@ -23,7 +23,7 @@ const API_STYLES = new Set(["auto", "chat_completions", "responses", "anthropic_
const EXCLUDED_VENDORS = new Set(["claude-cli", "codex", "openai-codex", "github-copilot", "google-antigravity", "google-gemini-cli", "ollama", "lmstudio", "lm-studio", "local"]);
const RESERVED_HEADERS = new Set(["authorization", "proxy-authorization", "x-api-key", "api-key", "x-goog-api-key", "cookie", "set-cookie", "host", "content-type", "content-length", "connection", "transfer-encoding", "te", "trailer", "upgrade", "keep-alive", "chatgpt-account-id", "x-opencode-session"]);
const INPUT_FIELDS = ["name", "vendorKey", "type", "protocol", "baseUrl", "authKind", "models", "defaultModelId", "secretValue", "apiStyle", "headers", "supportsReasoning", "supportedThinkingLevels", "contextWindow", "maxOutputTokens", "temperature"];
-const MODEL_FIELDS = ["id", "alias", "contextWindow", "contextWindowSource", "maxTokens", "maxTokensSource", "thinkingLevels", "defaultThinkingLevel", "thinkingProtocol", "supportsImages", "supportsDocuments", "availableForSubagents", "nativeWebSearch"];
+const MODEL_FIELDS = ["id", "alias", "contextWindow", "contextWindowSource", "maxTokens", "maxTokensSource", "thinkingLevels", "defaultThinkingLevel", "thinkingProtocol", "supportsReasoningEffort", "supportsImages", "supportsDocuments", "availableForSubagents", "nativeWebSearch"];
function invalid(): never {
// Never include input values, unknown field names, parser diagnostics or causes.
@@ -82,7 +82,7 @@ function validateModel(value: unknown): ModelBinding {
const thinking = value.defaultThinkingLevel;
if (thinking !== null && thinking !== "omit" && !(typeof thinking === "string" && (value.thinkingLevels as string[]).includes(thinking))) invalid();
if (value.thinkingProtocol !== undefined && value.thinkingProtocol !== "legacy" && value.thinkingProtocol !== "adaptive") invalid();
- for (const key of ["supportsImages", "supportsDocuments"] as const) {
+ for (const key of ["supportsImages", "supportsDocuments", "supportsReasoningEffort"] as const) {
if (value[key] !== undefined && value[key] !== null && typeof value[key] !== "boolean") invalid();
}
for (const key of ["availableForSubagents", "nativeWebSearch"] as const) {
diff --git a/packages/shared/src/types/models.ts b/packages/shared/src/types/models.ts
index 47d436f6b..c5d8dcbca 100644
--- a/packages/shared/src/types/models.ts
+++ b/packages/shared/src/types/models.ts
@@ -228,6 +228,8 @@ export type ModelBinding = {
defaultThinkingLevel: SessionThinkingLevel | null;
/** Provider request protocol used when thinking is enabled. */
thinkingProtocol?: ThinkingProtocol;
+ /** Chat Completions reasoning_effort override; absent/null keeps compatibility defaults. */
+ supportsReasoningEffort?: boolean | null;
/**
* User override for image input. `null` or absent follows the published
* models.dev capability. Once explicitly selected, either boolean is pinned
diff --git a/scripts/e2e-provider-api-style.mjs b/scripts/e2e-provider-api-style.mjs
index 50257705a..b1d6eea1c 100644
--- a/scripts/e2e-provider-api-style.mjs
+++ b/scripts/e2e-provider-api-style.mjs
@@ -3,12 +3,13 @@
import assert from "node:assert/strict";
import { spawn } from "node:child_process";
import { createRequire } from "node:module";
-import { mkdtemp, rm, writeFile } from "node:fs/promises";
+import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
import { tmpdir } from "node:os";
import { dirname, join } from "node:path";
import { fileURLToPath } from "node:url";
import { resolveElectronBinary } from "./e2e/boot.mjs";
+const reasoningOnly = process.argv.includes("--reasoning-effort");
const root = join(dirname(fileURLToPath(import.meta.url)), "..");
const require = createRequire(
join(root, "packages/agent-runtime/package.json"),
@@ -35,9 +36,16 @@ try {
},
nodePaths: [join(root, "apps/desktop/node_modules")],
});
+ let css = "";
+ if (reasoningOnly) {
+ for (const name of ["tokens", "base", "ui-kit", "settings", "providers", "model-config"]) {
+ css += (await readFile(join(root, `apps/desktop/src/styles/${name}.css`), "utf8")).replace(/@theme(?: inline)?/g, ":root") + "\n";
+ }
+ }
+ await writeFile(join(temp, "style.css"), css);
await writeFile(
join(temp, "index.html"),
- '<!doctype html><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src \'self\'; style-src \'self\' \'unsafe-inline\'"><title>Provider API format regression</title><body><script src="renderer.js"></script>',
+ '<!doctype html><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="default-src \'self\'; style-src \'self\' \'unsafe-inline\'"><link rel="stylesheet" href="style.css"><title>Provider API format regression</title><body><script src="renderer.js"></script>',
);
await writeFile(
join(temp, "main.cjs"),
@@ -50,7 +58,13 @@ app.whenReady().then(async () => {
window.webContents.on("console-message", (event) => console.error(event.message));
try {
await window.loadFile(path.join(__dirname, "index.html"));
- const result = await window.webContents.executeJavaScript("globalThis.providerApiStyleProbe()");
+ const result = ${reasoningOnly} ? [] : await window.webContents.executeJavaScript("globalThis.providerApiStyleProbe()");
+ if (${reasoningOnly}) {
+ for (const [width, height] of [[850, 600], [1000, 700], [1400, 900]]) {
+ window.setContentSize(width, height);
+ result.push(await window.webContents.executeJavaScript("globalThis.providerApiStyleProbe(true)"));
+ }
+ }
console.log("PROVIDER_API_STYLE_PROBE " + JSON.stringify(result));
app.quit();
} catch (error) {
@@ -91,7 +105,8 @@ app.whenReady().then(async () => {
const result = JSON.parse(line.slice("PROVIDER_API_STYLE_PROBE ".length));
console.log("PROVIDER_API_STYLE_PROBE " + JSON.stringify(result));
assert.equal(code, 0, output.slice(-6000));
- assert.equal(result.ok, true);
+ if (reasoningOnly) for (const item of result) assert.equal(item.ok, true);
+ else assert.equal(result.ok, true);
} finally {
await rm(temp, { recursive: true, force: true });
}
diff --git a/scripts/e2e/provider-api-style.tsx b/scripts/e2e/provider-api-style.tsx
index 5f2e72c23..227535d93 100644
--- a/scripts/e2e/provider-api-style.tsx
+++ b/scripts/e2e/provider-api-style.tsx
@@ -1,3 +1,4 @@
+import { verifyReasoningEffort } from "./provider-reasoning-effort";
import { createRoot } from "react-dom/client";
import { flushSync } from "react-dom";
import { createInstance } from "i18next";
@@ -13,7 +14,7 @@ import { copyProviderConfiguration } from "../../apps/desktop/src/components/set
import { CUSTOM_SERVICE } from "../../apps/desktop/src/components/settings/service-catalog";
import { api } from "../../apps/desktop/src/lib/api";
-declare global { var providerApiStyleProbe: () => Promise<unknown>; }
+declare global { var providerApiStyleProbe: (reasoningOnly?: boolean) => Promise<unknown>; }
const assert = (value: unknown, message: string) => { if (!value) throw new Error(message); };
const pause = (ms = 0) => new Promise((resolve) => setTimeout(resolve, ms));
/* Anchored menus mount, position and reveal on animation frames, so wait for a
@@ -34,10 +35,10 @@ const fixture = (apiStyle: string): ProviderPublic => ({
thinkingLevels: ["off"], defaultThinkingLevel: "off" }],
});
-globalThis.providerApiStyleProbe = async () => {
+globalThis.providerApiStyleProbe = async (reasoningOnly = false) => {
const i18n = createInstance();
await i18n.init({ lng: "en", resources: {
- en: { translation: catalogs.en }, "zh-CN": { translation: catalogs["zh-CN"] },
+ en: { translation: catalogs.en }, "zh-CN": { translation: catalogs["zh-CN"] }, de: { translation: catalogs.de },
}, interpolation: { escapeValue: false } });
const creates: ProviderCreateInput[] = [];
const updates: ProviderUpdateInput[] = [];
@@ -217,8 +218,13 @@ globalThis.providerApiStyleProbe = async () => {
await until(() => Boolean(searchInput()), "model capability settings");
};
try {
- for (const locale of ["en", "zh-CN"]) {
+ for (const locale of (reasoningOnly ? ["en", "zh-CN", "de"] : ["en", "zh-CN"])) {
await i18n.changeLanguage(locale);
+ if (reasoningOnly) {
+ await verifyReasoningEffort({ render, fixture, i18n, updates, click, control, until, frame });
+ results.push(`${locale}:reasoning-effort-auto-send-omit-save-reopen-protocol-switch`);
+ continue;
+ }
render();
const beforeStepfunCreate = creates.length;
const beforeStepfunDiscovery = discoveries.length;
@@ -397,6 +403,8 @@ globalThis.providerApiStyleProbe = async () => {
assert(JSON.stringify(original) === before, "edit/copy mutated source object");
results.push(`${locale}:${style}:edit-change-copy-cancel`);
}
+ await verifyReasoningEffort({ render, fixture, i18n, updates, click, control, until, frame });
+ results.push(`${locale}:reasoning-effort-auto-send-omit-save-reopen-protocol-switch`);
for (const [vendorKey, baseUrl, modelId] of [
["deepseek", "https://api.deepseek.com", "deepseek-v4-flash"],
["xai", "https://api.x.ai/v1", "grok-4.7"],
diff --git a/scripts/e2e/provider-reasoning-effort.ts b/scripts/e2e/provider-reasoning-effort.ts
new file mode 100644
index 000000000..14b11abe9
--- /dev/null
+++ b/scripts/e2e/provider-reasoning-effort.ts
@@ -0,0 +1,57 @@
+import type { i18n } from "i18next";
+import type { ProviderPublic, ProviderUpdateInput } from "@pi-desktop/shared";
+
+export async function verifyReasoningEffort({ render, fixture, i18n, updates, click, control, until, frame }: {
+ render: (props: { provider: ProviderPublic }) => void;
+ fixture: (apiStyle: string) => ProviderPublic;
+ i18n: i18n;
+ updates: ProviderUpdateInput[];
+ click: (element: HTMLElement | undefined | null) => void;
+ control: (key: string) => HTMLButtonElement | undefined;
+ until: (condition: () => boolean, label: string) => Promise<void>;
+ frame: () => Promise<void>;
+}) {
+ const assert = (condition: unknown, message: string) => { if (!condition) throw new Error(message); };
+ let provider = fixture("chat_completions");
+ provider = { ...provider, models: [{ ...provider.models[0], id: "deepseek-v4.1-flash" }] };
+ const trigger = () => [...document.querySelectorAll<HTMLButtonElement>(".settings-menu-select-trigger")]
+ .find((element) => element.getAttribute("aria-label") === i18n.t("settings.reasoningEffortParameter"));
+ render({ provider });
+ await until(() => Boolean(trigger()), "reasoning effort settings");
+ assert(trigger()?.textContent?.trim() === i18n.t("settings.reasoningEffortAuto"), "legacy binding must start on Auto");
+ await Promise.all(document.getAnimations().filter((animation) => animation.effect?.getTiming().iterations !== Infinity).map((animation) => animation.finished));
+ const assertFits = () => {
+ const bounds = trigger()!.getBoundingClientRect();
+ const panel = document.querySelector(".provider-chosen-reasoning-effort")!.getBoundingClientRect();
+ assert(bounds.left >= panel.left - 1 && bounds.right <= panel.right + 1 && bounds.right <= innerWidth, "reasoning effort control overflows the model panel");
+ };
+ assertFits();
+ for (const [key, value] of [
+ ["settings.reasoningEffortSend", true],
+ ["settings.reasoningEffortOmit", false],
+ ["settings.reasoningEffortAuto", null],
+ ] as const) {
+ trigger()?.scrollIntoView({ block: "center" });
+ await frame();
+ click(trigger());
+ await frame();
+ const option = [...document.querySelectorAll<HTMLButtonElement>(".settings-menu-select-option")]
+ .find((element) => element.textContent?.trim() === i18n.t(key));
+ assert(option, `missing reasoning effort choice ${key}`);
+ click(option);
+ const count = updates.length;
+ click(control("settings.saveProvider"));
+ await until(() => updates.length === count + 1, "save reasoning effort override");
+ const update = updates.at(-1)!;
+ assert(update.models?.[0].supportsReasoningEffort === value, "saved reasoning effort override differs from selection");
+ provider = { ...provider, ...update };
+ render({ provider });
+ await until(() => Boolean(trigger()), "reopen reasoning effort settings");
+ assert(trigger()?.textContent?.trim() === i18n.t(key), "reasoning effort choice lost on reopen");
+ assertFits();
+ }
+ for (const apiStyle of ["responses", "anthropic_messages"]) {
+ render({ provider: { ...provider, apiStyle } });
+ assert(!trigger(), `${apiStyle} must not offer the Completions-only setting`);
+ }
+}