























@@ -4,6 +4,7 @@ import { streamSimple } from "@mariozechner/pi-ai";
44import type { SettingsManager } from "@mariozechner/pi-coding-agent";
55import type { ThinkLevel } from "../../auto-reply/thinking.js";
66import type { OpenClawConfig } from "../../config/types.openclaw.js";
7+import { createDeepSeekV4OpenAICompatibleThinkingWrapper } from "../../plugin-sdk/provider-stream-shared.js";
78import {
89prepareProviderExtraParams as prepareProviderExtraParamsRuntime,
910type ProviderRuntimePluginHandle,
@@ -689,6 +690,12 @@ function applyPostPluginStreamWrappers(
689690ctx.agent.streamFn = createOpenAICompletionsToolsCompatWrapper(ctx.agent.streamFn);
690691691692if (!ctx.providerWrapperHandled) {
693+ctx.agent.streamFn = createDeepSeekV4OpenAICompatibleThinkingWrapper({
694+baseStreamFn: ctx.agent.streamFn,
695+thinkingLevel: ctx.thinkingLevel,
696+shouldPatchModel: isDeepSeekV4OpenAICompatibleModel,
697+});
698+692699// Guard Google-family payloads against invalid negative thinking budgets
693700// emitted by upstream model-ID heuristics for Gemini 3.1 variants.
694701ctx.agent.streamFn = createGoogleThinkingPayloadWrapper(ctx.agent.streamFn, ctx.thinkingLevel);
@@ -752,6 +759,22 @@ function applyPostPluginStreamWrappers(
752759log.warn(`ignoring invalid parallel_tool_calls param: ${summary}`);
753760}
754761762+function normalizeDeepSeekV4CandidateId(modelId: unknown): string | undefined {
763+if (typeof modelId !== "string") {
764+return undefined;
765+}
766+const withoutSuffix = modelId.trim().toLowerCase().split(":", 1)[0];
767+return withoutSuffix.split("/").pop();
768+}
769+770+function isDeepSeekV4OpenAICompatibleModel(model: Parameters<StreamFn>[0]): boolean {
771+const normalizedModelId = normalizeDeepSeekV4CandidateId(model.id);
772+return (
773+model.api === "openai-completions" &&
774+(normalizedModelId === "deepseek-v4-flash" || normalizedModelId === "deepseek-v4-pro")
775+);
776+}
777+755778/**
756779 * Apply extra params (like temperature) to an agent's streamFn.
757780 * Also applies verified provider-specific request wrappers, such as OpenRouter attribution.
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。