openclaw - ✅(Solved) Fix [Feature]: Allow per-model setting for Deepseek `reasoning_content` fix [3 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#75105Fetched 2026-05-01 05:38:09
View on GitHub
Comments
1
Participants
2
Timeline
2
Reactions
2
Author
Timeline (top)
commented ×1labeled ×1

Proposal to allow per-model configuration for reasoning_content fix for Deepseek v4 or any other (future) models that might require it, which is also required right now for any API providers that offer DeepSeek Model access.

Root Cause

Proposal to allow per-model configuration for reasoning_content fix for Deepseek v4 or any other (future) models that might require it, which is also required right now for any API providers that offer DeepSeek Model access.

PR fix notes

PR #71473: fix(openai): replay DeepSeek tool reasoning_content

Description (problem / solution / changelog)

Fixes #71455.

Summary

  • detect DeepSeek-family OpenAI-compatible models by model id, so Ollama/custom hosted deepseek-* models get DeepSeek thinking compat
  • inject blank reasoning_content: "" on assistant messages with replayed tool_calls when DeepSeek thinking mode is active
  • preserve the disabled-thinking path without adding reasoning_content

Test plan

  • pnpm test src/agents/openai-transport-stream.test.ts extensions/deepseek/index.test.ts

Changed files

  • src/agents/openai-completions-compat.ts (modified, +5/-1)
  • src/agents/openai-transport-stream.test.ts (modified, +171/-0)
  • src/agents/openai-transport-stream.ts (modified, +32/-8)
  • src/agents/provider-attribution.ts (modified, +9/-2)

PR #71146: fix: replay DeepSeek reasoning_content on tool-turn history

Description (problem / solution / changelog)

Problem

Under DeepSeek V4 thinking mode, when historical assistant tool-call messages lack the reasoning_content field, the API returns a 400 error:

The reasoning_content in the thinking mode must be passed back to the API.

Root Cause

convertMessages does not generate a reasoning_content field when converting assistant tool-call history to OpenAI format. DeepSeek thinking mode strictly requires this field to be present.

Fix

In buildOpenAICompletionsParams, after convertMessages, insert injectDeepSeekReasoningReplay to inject reasoning_content as a fallback for DeepSeek model assistant tool-call messages.

Fallback priority (highest to lowest):

  1. Existing non-empty reasoning_content → keep as-is
  2. reasoning field → copy
  3. reasoning_text field → copy
  4. Replay signature key content extraction
  5. Assistant content string → copy
  6. None of the above → empty string "" (verified safe against live API)

Only applied to models with provider=deepseek or baseUrl containing deepseek.com.

Verification

  • Unit tests cover all 5 fallback paths
  • Production dry-run: 1493 tool-turns, missingAfterPatch: 0
  • Production live test: 0 errors after applying the patch

Related

Requires companion fix in @mariozechner/pi-ai buildParams for the pi-ai streaming path: https://github.com/snowzlm/pi-mono/pull/1

Changed files

  • src/agents/openai-transport-stream.test.ts (modified, +352/-0)
  • src/agents/openai-transport-stream.ts (modified, +107/-0)

Code Example

{
  "id": "deepseek/deepseek-v4-flash",
  "compat": {
    "reasoningFormat": "deepseek"
  }
}
RAW_BUFFERClick to expand / collapse

Summary

Proposal to allow per-model configuration for reasoning_content fix for Deepseek v4 or any other (future) models that might require it, which is also required right now for any API providers that offer DeepSeek Model access.

Problem to solve

Recent fixes (https://github.com/openclaw/openclaw/issues/74374, https://github.com/openclaw/openclaw/pull/71473, https://github.com/openclaw/openclaw/pull/71146 etc) fix for the fact that Deepseek v4 models despite generally using OpenAI style API syntax, need a bit of special treatment.

However, the fixes only currently apply when the model provider is literally deepseek, and the model names are literally deepseek-v4-flash or deepseek-v4-pro. This means the fixes don't kick in when using a custom alternative provider who offers Deepseek access (e.g. Requesty) and if such a provider names their model ID differently (e.g. deepseek/deepseek-v4-pro rather than just deepseek-v4-pro.

Proposed solution

Proposal

Introduce an additional optional configuration key compat.reasoningFormat key at the model level.

{
  "id": "deepseek/deepseek-v4-flash",
  "compat": {
    "reasoningFormat": "deepseek"
  }
}

... and let that trigger the Deepseek v4 specific fixes to reasoning_context.

Details

This would feed into three existing code paths:

Stream wrapping — the universal wrapper switch (e.g. in provider-stream-CNYlhjpk.js) would check model.compat?.reasoningFormat and apply the corresponding thinking wrapper, bypassing the plugin-level wrapStreamFn gate.

Wrapper guard — the DeepSeek V4 wrapper (inside createDeepSeekV4ThinkingWrapper) already checks isDeepSeekV4ModelId(model.id). This is fine — it stays as-is, since the model ID already identifies the model family. What's needed is a path for non-plugin providers to reach the wrapper.

Response renderingresolveOpenAICompletionsCompatDefaults would set thinkingFormat based on compat.reasoningFormat in addition to the current endpointClass/isDefaultRouteProvider checks. This avoids having to add every proxy provider ID to the isDeepSeek list in provider-model-compat-C_Djlg3U.js.

Alternatives considered

It seems obvious that this needs to be a per-model setting, rather than hard-coded per provider or for specific model names. Allowing it as an individual setting for each model that needs it lays the foundation to also apply other required per-model fixes in a consistently expressed manner, if necessary.

Impact

Positively affects anyone who accesses Deepseek models through any 3rd party provider (Requesty, Wisgate, Openrouter etc.) since without this fix, Deepseek v4 models are practically not useable.

Positively affects anyone needing to implement future per-model fixes.

Has no negative effects or drawbacks.

Evidence/examples

Prototype

My Lobster and I have implemented a more shoddy work-around in my local install, not introducing a separate key, but just hard-coding a requesty-deepseek provider into it, but it shows that it works and isn't a massive effort.

#FileChange
1extensions/deepseek/index.jsAdd aliases: ["requesty-deepseek"]
2extensions/deepseek/index.jsFix isModernModelRef for prefixed model IDs
3extensions/deepseek/index.jsFix augmentModelCatalog to read from both "deepseek" and "requesty-deepseek" config keys
4stream-BUfum08N.jsFix isDeepSeekV4ModelId for prefixed IDs + remove model.provider !== "deepseek" guard
5provider-model-compat-C_Djlg3U.jsAdd "requesty-deepseek" to isDeepSeek and isNonStandard

Additional information

No response

extent analysis

TL;DR

Introduce a per-model configuration key compat.reasoningFormat to trigger Deepseek v4 specific fixes for non-Deepseek providers.

Guidance

  • Add an optional compat.reasoningFormat key at the model level, as proposed, to allow per-model configuration for Deepseek v4 fixes.
  • Update the createDeepSeekV4ThinkingWrapper function to check for the compat.reasoningFormat key in addition to the model ID.
  • Modify the resolveOpenAICompletionsCompatDefaults function to set thinkingFormat based on compat.reasoningFormat.
  • Test the changes with different model providers and IDs to ensure the fixes are applied correctly.

Example

{
  "id": "deepseek/deepseek-v4-flash",
  "compat": {
    "reasoningFormat": "deepseek"
  }
}

Notes

The proposed solution seems to be a good approach, as it allows for per-model configuration and avoids hard-coding provider-specific fixes. However, it's essential to test the changes thoroughly to ensure they work as expected.

Recommendation

Apply the proposed workaround by introducing the compat.reasoningFormat key and updating the relevant functions. This approach provides a flexible and scalable solution for applying per-model fixes.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix [Feature]: Allow per-model setting for Deepseek `reasoning_content` fix [3 pull requests, 1 comments, 2 participants]