Skip to content

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

fix(provider): suppress DeepSeek reasoning effort

vastsa9fea8a3468a1
diff --git a/docs/spec/03-runtime/11-provider-model-system.md b/docs/spec/03-runtime/11-provider-model-system.md
index 67047b604..30f0f76f8 100644
--- a/docs/spec/03-runtime/11-provider-model-system.md
+++ b/docs/spec/03-runtime/11-provider-model-system.md
@@ -127,7 +127,9 @@ Non-official DeepSeek endpoints also set `requiresNonEmptyReasoningReplay` so
missing reasoning is filled with a documented placeholder instead of `""`
(OpenCode / third-party relays reject empty echoes after compaction; see
ADR 0256 / #296). Official `deepseek.com` rows keep empty-string fill (#223).
-The overlay does not change `thinkingFormat`.
+Both official and relay rows set `supportsReasoningEffort: false`; DeepSeek
+does not accept the generic OpenAI `reasoning_effort` request field even when
+thinking is enabled. The overlay does not change `thinkingFormat`.
Anthropic Messages requests set `forceAdaptiveThinking: true` when the
models.dev record publishes a reasoning `effort` option and no
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index 4124df4cf..cd4ca9e3a 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -1640,6 +1640,9 @@ identify the platform validation still needed.
turns that had no thinking. Non-official DeepSeek-family relays use real
retained thinking when available, otherwise the documented non-empty
placeholder from ADR 0256 — never a silent empty string after compaction.
+ The request omits the generic OpenAI `reasoning_effort` field because
+ DeepSeek endpoints do not accept it, while the selected thinking mode still
+ follows the endpoint's own wire format.
The request does not switch `thinkingFormat` to `"deepseek"` solely because
the model id contains `"deepseek"`. Official `api.deepseek.com` rows keep
URL-based DeepSeek `thinkingFormat` from pi-ai.
diff --git a/docs/spec/08-meta/decisions-log.md b/docs/spec/08-meta/decisions-log.md
index 427e3a201..8982f39a2 100644
--- a/docs/spec/08-meta/decisions-log.md
+++ b/docs/spec/08-meta/decisions-log.md
@@ -78,7 +78,7 @@ This log freezes previously open questions into concrete decisions.
| D023 | Provider coverage goal | **Universal market coverage** (not a tiny fixed vendor list) | Globalization + real coding workflows |
| D024 | Coverage strategy | **pi-ai native providers + first-class OpenAI-compatible + custom providers** | Maximum reach without rewriting every SDK |
| D308 | Zhipu / Z.AI named endpoint presets | **Amend D024 / ADR 0116: the add-provider Service select offers four OpenAI-compatible Zhipu endpoints — China and international standard API plus GLM Coding Plan — with locked published URLs and models.dev `vendorKey`s (`zhipuai`, `zhipuai-coding-plan`, `zai`, `zai-coding-plan`). No new apiStyle or wire adapter. Completions requests on those URLs use `thinkingFormat: "zai"` and `zaiToolStream: true`. Custom endpoint remains available.** | Users had to know which BigModel / Z.AI URL to paste, and `vendorKey: "custom"` could catalog-match the wrong API vs Coding Plan record. Named presets keep coverage on the existing OpenAI-compatible path. See ADR 0155 and E2E-005D. |
-| D389 | DeepSeek reasoning_content replay on aggregators | **Amend D024: Completions requests for DeepSeek-family models set `requiresReasoningContentOnAssistantMessages: true` when the row `vendorKey`, base URL, model id, or catalog `family` identifies DeepSeek. Do not change `thinkingFormat` for that match. pi-ai still auto-detects official `deepseek.com` URLs.** | DeepSeek thinking mode 400s if any replayed assistant message omits `reasoning_content`. PI-Desktop stores a UUID as `model.provider`, so SiliconFlow, Volcengine, and custom gateways never match pi-ai's `provider === "deepseek"` check. See E2E-005E. |
+| D389 | DeepSeek reasoning_content replay on aggregators | **Amend D024: Completions requests for DeepSeek-family models set `requiresReasoningContentOnAssistantMessages: true` and `supportsReasoningEffort: false` when the row `vendorKey`, base URL, model id, or catalog `family` identifies DeepSeek. Do not change `thinkingFormat` for that match. pi-ai still auto-detects official `deepseek.com` URLs.** | DeepSeek thinking mode 400s if any replayed assistant message omits `reasoning_content` or if a relay receives the unsupported generic `reasoning_effort` field. PI-Desktop stores a UUID as `model.provider`, so SiliconFlow, Volcengine, and custom gateways never match pi-ai's `provider === "deepseek"` check. See E2E-005E. |
| D424 | DeepSeek reasoning across compaction | **Amend D389 / ADR 0136: restore thinkingSignature on history rebuild; store recent thinking in checkpoint `details.retainedReasoning` and replay after the summary; non-official DeepSeek Completions rows set `requiresNonEmptyReasoningReplay` so the pi-ai patch uses a documented placeholder instead of `""`. Official deepseek.com keeps empty-string fill.** | OpenCode / third-party DeepSeek V4.1 Flash 400s after compaction when empty reasoning is echoed (#296). |
| D309 | Add-provider common path is Service + key | **Amend D308 / ADR 0116 / ADR 0155: a new add-provider dialog starts with only Service. Named endpoints (Zhipu / Z.AI, OpenCode Go) then show Service + API key and a host summary. Custom endpoint then shows Name, Base URL, and API key. Name (named) and API format (custom) stay in Advanced. OpenCode Go is a Service option. No stepper or vendor-card grid.** | Stacking Name, Base URL, and API format next to Service made a known service look like a generic gateway. The common path should be pick a service and paste a key. See ADR 0156 and E2E-005 / E2E-005B / E2E-005D. |
| D310 | Custom API format stays beside the key; Service lists top models.dev vendors | **Amend D309 / ADR 0155 / ADR 0156: Custom endpoint shows Name + Base URL, then API key beside API format on the common path. Named Service options expand to models.dev-backed international and China first-party endpoints (OpenAI, Anthropic, Google, OpenRouter, Groq, xAI, Mistral, Together, Fireworks, OpenCode Go, Z.AI, DeepSeek, Qwen, Moonshot, Zhipu, SiliconFlow, Volcengine, MiniMax Anthropic Messages, MiniMax OpenAI-compatible, Kimi For Coding), each with a published URL and wire style. Named display names stay in Advanced.** | Custom gateways need the format next to the key, while named vendors should cover the usual domestic and international APIs without a closed allowlist. See E2E-005 / E2E-005B / E2E-005D. |
diff --git a/docs/zh-CN/spec/03-runtime/11-provider-model-system.md b/docs/zh-CN/spec/03-runtime/11-provider-model-system.md
index 19cb2ac9e..dec4160c9 100644
--- a/docs/zh-CN/spec/03-runtime/11-provider-model-system.md
+++ b/docs/zh-CN/spec/03-runtime/11-provider-model-system.md
@@ -118,7 +118,8 @@ OpenAI 风格的 Copilot 线路 API 仍将令牌作为请求密钥签名;所
`reasoning_content`。非官方 DeepSeek 端点还会设置 `requiresNonEmptyReasoningReplay`,
用文档化的非空占位符而不是 `""` 填补缺失推理(OpenCode / 第三方中转在压缩后拒绝空回传;
见 ADR 0256 / #296)。官方 `deepseek.com` 行仍使用空串回填(#223)。该覆盖不改
-`thinkingFormat`。
+`thinkingFormat`。官方与中转行都会设置 `supportsReasoningEffort: false`;即使开启思考,
+DeepSeek 也不接受通用 OpenAI 的 `reasoning_effort` 请求字段。
当 Pi catalog 记录发布了推理 `effort` 选项且没有 `budget_tokens` 选项时
(例如 Opus 4.7+、Opus 5.x、Fable),Anthropic Messages 请求会设置
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 e9e213c88..049b14a37 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
@@ -455,7 +455,7 @@ task-candidate E2E 从请求工作树运行,但使用主工作区已经准备
- **前提条件**:已配置一个 Base URL 不含 `deepseek.com` 的 OpenAI 兼容提供商,模型 ID 属于 DeepSeek 系(例如硅基流动 `deepseek-ai/DeepSeek-V3.2`),并开启思考模式。
- **步骤**:1) 在思考模式下开始会话。2) 完成若干回合,其中至少一条助手回复没有思考文本。3) 再发一条提示,使历史被回放到提供商。
-- **预期**:后续 Completions 请求的每条 assistant 消息都带推理字段。官方 `api.deepseek.com` 行对无思考内容的回合仍可使用 `""`。非官方 DeepSeek 系中转在可用时回传保留的真实思考,否则使用 ADR 0256 文档化的非空占位符——压缩后不得静默回填空串。不会仅因模型 ID 含 `"deepseek"` 就把 `thinkingFormat` 改成 `"deepseek"`。官方 `api.deepseek.com` 行仍使用 pi-ai 按 URL 检测的 DeepSeek `thinkingFormat`。
+- **预期**:后续 Completions 请求的每条 assistant 消息都带推理字段。官方 `api.deepseek.com` 行对无思考内容的回合仍可使用 `""`。非官方 DeepSeek 系中转在可用时回传保留的真实思考,否则使用 ADR 0256 文档化的非空占位符——压缩后不得静默回填空串。请求不会携带通用 OpenAI 的 `reasoning_effort` 字段,因为 DeepSeek 端点不接受它;已选的思考模式仍按端点自身线路发送。不会仅因模型 ID 含 `"deepseek"` 就把 `thinkingFormat` 改成 `"deepseek"`。官方 `api.deepseek.com` 行仍使用 pi-ai 按 URL 检测的 DeepSeek `thinkingFormat`。
- **链接规格**:`03-runtime/11-provider-model-system.md`、
`03-runtime/12-provider-config-schema.md`
- **验收**:B(提供商 Completions 兼容)
diff --git a/docs/zh-CN/spec/08-meta/decisions-log.md b/docs/zh-CN/spec/08-meta/decisions-log.md
index 3fa8efe6d..c411554e5 100644
--- a/docs/zh-CN/spec/08-meta/decisions-log.md
+++ b/docs/zh-CN/spec/08-meta/decisions-log.md
@@ -80,7 +80,7 @@
| D023 | 提供商覆盖目标 | **全球市场覆盖**(不是一个很小的固定供应商列表) | 全球化+真实的编码工作流程 |
| D024 | 覆盖策略 | **pi-ai 原生提供商 + 一流的 OpenAI 兼容 + 自定义提供商** | 无需重写每个 SDK 即可实现最大覆盖范围 |
| D308 | 智谱 / Z.AI 命名端点预设 | **修订 D024 / ADR 0116:添加服务的「服务」下拉框提供四套 OpenAI 兼容智谱端点——国内/国际标准 API 以及 GLM Coding Plan——锁定已发布 URL,并写入 models.dev `vendorKey`(`zhipuai`、`zhipuai-coding-plan`、`zai`、`zai-coding-plan`)。不新增 apiStyle 或线路适配器。这些 URL 上的 Completions 请求使用 `thinkingFormat: "zai"` 与 `zaiToolStream: true`。自定义端点仍可用。** | 用户此前必须手填 BigModel / Z.AI 地址,且 `vendorKey: "custom"` 可能把 API 与 Coding Plan 目录配错。命名预设把覆盖范围留在现有 OpenAI 兼容路径上。见 ADR 0155 与 E2E-005D。 |
-| D389 | 聚合端点上回放 DeepSeek 的 reasoning_content | **修订 D024:DeepSeek 系模型的 Completions 请求在行 `vendorKey`、Base URL、模型 ID 或目录 `family` 能识别为 DeepSeek 时设置 `requiresReasoningContentOnAssistantMessages: true`。该匹配不改 `thinkingFormat`。pi-ai 仍对官方 `deepseek.com` URL 做自动检测。** | DeepSeek 思考模式在任一条回放的 assistant 消息缺少 `reasoning_content` 时会 400。PI-Desktop 把 UUID 存成 `model.provider`,硅基流动、火山方舟和自定义网关永远匹配不上 pi-ai 的 `provider === "deepseek"` 判断。见 E2E-005E。 |
+| D389 | 聚合端点上回放 DeepSeek 的 reasoning_content | **修订 D024:当行的 `vendorKey`、Base URL、模型 ID 或目录 `family` 能识别为 DeepSeek 时,DeepSeek 系模型的 Completions 请求设置 `requiresReasoningContentOnAssistantMessages: true` 与 `supportsReasoningEffort: false`。该匹配不改 `thinkingFormat`。pi-ai 仍对官方 `deepseek.com` URL 做自动检测。** | DeepSeek 思考模式在任一条回放的 assistant 消息缺少 `reasoning_content`,或中转收到不支持的通用 `reasoning_effort` 字段时会 400。PI-Desktop 把 UUID 存成 `model.provider`,硅基流动、火山方舟和自定义网关永远匹配不上 pi-ai 的 `provider === "deepseek"` 判断。见 E2E-005E。 |
| D424 | 压缩后保留 DeepSeek 推理 | **修订 D389 / ADR 0136:历史重建时恢复 thinkingSignature;把最近思考写入检查点 `details.retainedReasoning` 并在摘要后回放;非官方 DeepSeek Completions 行设置 `requiresNonEmptyReasoningReplay`,使 pi-ai 补丁使用文档化占位符而非 `""`。官方 deepseek.com 仍用空串回填。** | OpenCode / 第三方 DeepSeek V4.1 Flash 在压缩后回传空推理字段会 400(#296)。 |
| D309 | 添加服务的常见路径是服务 + 密钥 | **修订 D308 / ADR 0116 / ADR 0155:新建添加服务对话框先只显示服务。命名端点(智谱 / Z.AI、OpenCode Go)随后显示服务 + API 密钥和主机摘要。自定义端点随后显示名称、Base URL 和 API 密钥。名称(命名行)与接口格式(自定义行)放在高级里。OpenCode Go 是服务选项。没有步进器或厂商卡片网格。** | 把名称、Base URL 和接口格式与服务叠在一起,让已知服务看起来像通用网关。常见路径应是选服务并粘贴密钥。见 ADR 0156 与 E2E-005 / E2E-005B / E2E-005D。 |
| D310 | 自定义接口格式与密钥并排;服务列出 models.dev 主流厂商 | **修订 D309:自定义端点在常见路径上并排显示 API 密钥与接口格式。服务下拉框按国际 / 国内列出 models.dev 的主流厂商端点。命名服务的显示名称仍在高级里。** | 自定义网关需要在密钥旁选择格式;命名厂商应覆盖常用国内外 API。见 E2E-005。 |
diff --git a/packages/agent-runtime/src/provider-binding.test.ts b/packages/agent-runtime/src/provider-binding.test.ts
index fcf83fd6e..77a28a332 100644
--- a/packages/agent-runtime/src/provider-binding.test.ts
+++ b/packages/agent-runtime/src/provider-binding.test.ts
@@ -778,6 +778,7 @@ describe("buildProviderModel OpenAI-compatible role compatibility", () => {
expect(model.provider).toBe("siliconflow-cn");
expect(model.compat).toMatchObject({
requiresReasoningContentOnAssistantMessages: true,
+ supportsReasoningEffort: false,
requiresNonEmptyReasoningReplay: true,
supportsDeveloperRole: false,
});
@@ -1565,6 +1566,7 @@ describe("DeepSeek-family relay reasoning replay (#296)", () => {
expect(assistants[1].reasoning_content).toBe(
DEEPSEEK_REASONING_REPLAY_PLACEHOLDER,
);
+ expect(requests[0].reasoning_effort).toBeUndefined();
});
});
diff --git a/packages/shared/src/provider-presets.test.ts b/packages/shared/src/provider-presets.test.ts
index 6db92afe6..083dae6d9 100644
--- a/packages/shared/src/provider-presets.test.ts
+++ b/packages/shared/src/provider-presets.test.ts
@@ -91,7 +91,10 @@ describe("DeepSeek reasoning replay", () => {
);
expect(
deepseekRequestCompat({ baseUrl: "https://api.deepseek.com" }),
- ).toEqual({ requiresReasoningContentOnAssistantMessages: true });
+ ).toEqual({
+ requiresReasoningContentOnAssistantMessages: true,
+ supportsReasoningEffort: false,
+ });
});
it("matches aggregator and custom DeepSeek-family models without a deepseek.com URL", () => {
@@ -103,6 +106,7 @@ describe("DeepSeek reasoning replay", () => {
}),
).toEqual({
requiresReasoningContentOnAssistantMessages: true,
+ supportsReasoningEffort: false,
requiresNonEmptyReasoningReplay: true,
});
expect(DEEPSEEK_REASONING_REPLAY_PLACEHOLDER.length).toBeGreaterThan(0);
diff --git a/packages/shared/src/provider-presets.ts b/packages/shared/src/provider-presets.ts
index 2b68a5da8..f38e73d78 100644
--- a/packages/shared/src/provider-presets.ts
+++ b/packages/shared/src/provider-presets.ts
@@ -522,6 +522,8 @@ export const DEEPSEEK_REASONING_REPLAY_PLACEHOLDER =
export type DeepSeekRequestCompat = {
requiresReasoningContentOnAssistantMessages: true;
+ /** DeepSeek endpoints reject the OpenAI-style `reasoning_effort` field. */
+ supportsReasoningEffort: false;
/** When set, missing reasoning is filled with {@link DEEPSEEK_REASONING_REPLAY_PLACEHOLDER}. */
requiresNonEmptyReasoningReplay?: true;
};
@@ -535,10 +537,14 @@ export function deepseekRequestCompat(input: {
}): DeepSeekRequestCompat | undefined {
if (!isDeepSeekReasoningReplay(input)) return undefined;
if (isOfficialDeepSeekEndpoint(input)) {
- return { requiresReasoningContentOnAssistantMessages: true };
+ return {
+ requiresReasoningContentOnAssistantMessages: true,
+ supportsReasoningEffort: false,
+ };
}
return {
requiresReasoningContentOnAssistantMessages: true,
+ supportsReasoningEffort: false,
requiresNonEmptyReasoningReplay: true,
};
}