Skip to content

fix(deepseek): expose V4 max thinking levels - #73008

Merged
hxy91819 merged 2 commits into
openclaw:mainfrom
ai-hpc:fix/deepseek-v4-thinking-profile
Apr 30, 2026
Merged

hxy91819 merged 2 commits into
openclaw:mainfrom
ai-hpc:fix/deepseek-v4-thinking-profile

Conversation

@ai-hpc

@ai-hpc ai-hpc commented Apr 27, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Problem: Native deepseek/deepseek-v4-pro and deepseek/deepseek-v4-flash rejected /think max and /think xhigh before request construction.
  • Why it matters: DeepSeek V4 stream handling already maps max reasoning requests, but users could not select those levels through OpenClaw thinking validation.
  • What changed: Added a DeepSeek V4 resolveThinkingProfile with off|minimal|low|medium|high|xhigh|max, added regression coverage, and documented the supported levels.
  • What did NOT change (scope boundary): No OpenRouter behavior, no core thinking resolver changes, no changelog entry.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

Root Cause (if applicable)

  • Root cause: The DeepSeek provider registered the V4 stream wrapper, but did not expose a provider resolveThinkingProfile, so thinking validation fell back to the base levels only.
  • Missing detection / guardrail: Existing DeepSeek tests covered payload mapping after a level was accepted, but not provider-profile level exposure.
  • Contributing context (if known): DeepSeek V4 request shaping already handled xhigh/max via the stream wrapper.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: extensions/deepseek/index.test.ts
  • Scenario the test should lock in: DeepSeek V4 models expose xhigh and max; non-V4 DeepSeek models do not opt into the V4 profile.
  • Why this is the smallest reliable guardrail: The bug was in provider profile registration, so the provider plugin test directly exercises the missing hook.
  • Existing test that already covers this (if any): Existing tests covered V4 payload mapping, not level acceptance.
  • If no new test is added, why not: N/A

User-visible / Behavior Changes

/think xhigh and /think max are accepted for native DeepSeek V4 Flash and Pro models.

Diagram (if applicable)

Before:
[/think max] -> [DeepSeek provider has no profile] -> [base levels only] -> [rejected]

After:
[/think max] -> [DeepSeek V4 profile] -> [max accepted] -> [stream wrapper maps request]

Additional live test result:

Human verified with Deepseek API Key:

DEEPSEEK_LIVE_TEST=1 OPENCLAW_LIVE_DEEPSEEK_MODEL=deepseek-v4-pro pnpm test:live extensions/deepseek/deepseek.live.test.ts -- --reporter=verbose

RUN  v4.1.5

✓ extensions/deepseek/deepseek.live.test.ts > deepseek plugin live > returns assistant text from the bundled V4 model catalog 1103ms
✓ extensions/deepseek/deepseek.live.test.ts > deepseek plugin live > accepts V4 thinking replay after a prior provider tool call 1299ms

Test Files  1 passed (1)
Tests       2 passed (2)
Duration    5.18s

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation extensions: deepseek size: S labels Apr 27, 2026
@greptile-apps

greptile-apps Bot commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds a resolveThinkingProfile hook to the DeepSeek provider plugin so that V4 Flash and V4 Pro models expose the xhigh and max thinking levels, fixing the rejection of /think max before request construction. The implementation is focused, the regression test covers both the positive V4 path and the negative non-V4 path, and both documentation files are updated correctly.

Confidence Score: 5/5

Safe to merge — fixes a clear missing registration with no behaviour changes outside the V4 thinking path.

Only a P2 style finding (minor duplication between index.ts and stream.ts). The fix is correct, well-tested, and properly scoped.

No files require special attention.

Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/deepseek/index.ts
Line: 23-26

Comment:
**Duplicate `isDeepSeekV4ModelId` helper**

`stream.ts` already defines a private `isDeepSeekV4ModelId` that does exact-match comparison, while this new version adds `.toLowerCase()` first. The logic is effectively the same for real catalog IDs, but the two definitions can drift. Consider exporting this helper from a shared location (e.g. `./model-ids.js`) and importing it in both files to keep them in sync.

How can I resolve this? If you propose a fix, please make it concise.

Reviews (2): Last reviewed commit: "fix(deepseek): expose v4 max thinking le..." | Re-trigger Greptile

@ai-hpc
ai-hpc force-pushed the fix/deepseek-v4-thinking-profile branch 2 times, most recently from 8a70203 to 908365b Compare April 28, 2026 03:20
@ai-hpc

ai-hpc commented Apr 28, 2026

Copy link
Copy Markdown
Member Author

@greptile-apps

@ai-hpc
ai-hpc force-pushed the fix/deepseek-v4-thinking-profile branch 4 times, most recently from 3f95d42 to 4a95e3c Compare April 28, 2026 05:11
@ai-hpc

ai-hpc commented Apr 28, 2026

Copy link
Copy Markdown
Member Author

@vincentkoc Could you review this PR, please ?
Thanks.

@clawsweeper

clawsweeper Bot commented Apr 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes:

The PR adds a DeepSeek V4 provider thinking profile for native V4 Flash/Pro models, shares the V4 model matcher, adds regression coverage, and updates DeepSeek/thinking docs plus the changelog.

Maintainer follow-up before merge:

This is already a narrow open implementation PR for a valid provider-owned bug; the remaining work is maintainer review, CI/changed-gate confirmation, and merge handling rather than a separate ClawSweeper repair PR.

Security review:

Security review cleared: Security review cleared: the patch only changes DeepSeek provider logic, targeted tests, docs, and changelog, with no CI, dependency, secret, package publishing, or executable supply-chain changes.

Review details

Best possible solution:

Land the provider-owned DeepSeek V4 thinking profile after maintainer review and green required checks, then close the native DeepSeek reports it covers while keeping the OpenRouter-specific follow-up separate.

Do we have a high-confidence way to reproduce the issue?

Yes. A high-confidence static reproduction exists on current main: /think xhigh or /think max reaches directive validation, DeepSeek has no provider profile, the base profile omits those levels, and the directive is rejected before the V4 stream wrapper can map the payload.

Is this the best way to solve the issue?

Yes. The PR uses the narrowest maintainable fix: DeepSeek owns the model-specific level exposure, while the existing shared DeepSeek V4 transport wrapper continues to handle request shaping without changing core thinking fallback behavior.

Acceptance criteria:

  • pnpm test extensions/deepseek/index.test.ts
  • pnpm check:changed

What I checked:

  • Current main lacks provider profile hook: The DeepSeek plugin on current main registers catalog, replay hooks, the V4 stream wrapper, and isModernModelRef, but it does not register resolveThinkingProfile, so provider-specific xhigh/max exposure cannot happen there. (extensions/deepseek/index.ts:48, de1ac12f1c04)
  • Validation falls back to base levels: The shared resolver asks resolveProviderThinkingProfile first, then falls back to the base profile; base levels are only off|minimal|low|medium|high, with xhigh only appended by catalog/legacy hooks and no generic max append path. (src/auto-reply/thinking.ts:161, de1ac12f1c04)
  • Unsupported directive rejection happens before transport: Directive handling rejects an explicit /think level when isThinkingLevelSupported returns false, matching the reported pre-request rejection for /think xhigh and /think max. (src/auto-reply/reply/directive-handling.impl.ts:303, de1ac12f1c04)
  • Existing transport already maps max effort: The existing DeepSeek V4 stream wrapper maps xhigh and max thinking levels to reasoning_effort: "max", so the remaining bug is provider-level level exposure, not payload construction. (src/plugin-sdk/provider-stream-shared.ts:246, de1ac12f1c04)
  • PR head adds the missing provider-owned profile: The latest PR patch adds a DeepSeek V4 thinking profile with off|minimal|low|medium|high|xhigh|max, returns it only for V4 model ids, wires it through resolveThinkingProfile, and shares the V4 matcher from models.ts. (extensions/deepseek/index.ts:1, ef561a59debe)
  • PR head adds focused regression coverage and docs: The patch adds a DeepSeek provider test asserting V4 Flash/Pro expose the extended level set while deepseek-chat and deepseek-reasoner do not opt into the V4 profile, and it updates docs/providers/deepseek.md, docs/tools/thinking.md, and CHANGELOG.md. (extensions/deepseek/index.test.ts:110, ef561a59debe)

Likely related people:

  • steipete: Remote commit history and current code show Peter carried the shared thinking-profile/max-level resolver work and recent DeepSeek V4 replay/provider-stream maintenance this PR builds on. (role: recent maintainer and adjacent owner; confidence: high; commits: 6ce17db11aa1, f1805ab54d63, 62997f7fcec1; files: src/auto-reply/thinking.ts, src/plugin-sdk/provider-stream-shared.ts, extensions/deepseek/stream.ts)
  • lsdsjy: Remote commit history identifies feat(deepseek): support v4 models as adding the DeepSeek V4 catalog/provider/docs/stream surface adjusted by this PR. (role: introduced relevant DeepSeek V4 feature path; confidence: high; commits: 7d1891e6e63d; files: extensions/deepseek/index.ts, extensions/deepseek/models.ts, extensions/deepseek/stream.ts)
  • amknight: Recent DeepSeek provider-policy work maintained adjacent DeepSeek catalog/model metadata behavior and imported the same model module now used for the shared V4 matcher. (role: recent adjacent maintainer; confidence: medium; commits: 8f2dd02d2df6; files: extensions/deepseek/provider-policy-api.ts, extensions/deepseek/provider-policy-api.test.ts, extensions/deepseek/models.ts)

Remaining risk / open question:

  • Current-head CI was not complete in the check-runs snapshot, so maintainers should wait for required checks before merge.
  • This read-only review did not run local or live tests; the PR body reports a human DeepSeek live test, but repository validation still needs CI or maintainer-run proof.

Codex review notes: model gpt-5.5, reasoning high; reviewed against de1ac12f1c04.

@ai-hpc
ai-hpc force-pushed the fix/deepseek-v4-thinking-profile branch 2 times, most recently from 8c2152d to 00dfe9f Compare April 29, 2026 01:28
@ai-hpc

ai-hpc commented Apr 29, 2026

Copy link
Copy Markdown
Member Author

Addressed the remaining maintainability risk.

The PR previously had two separate DeepSeek V4 model-id helpers:

  • one in extensions/deepseek/index.ts
  • one in extensions/deepseek/stream.ts

I moved the matcher into the existing DeepSeek-local model module, extensions/deepseek/models.ts, and now both the provider entry (resolveThinkingProfile / isModernModelRef) and stream wrapper use the same isDeepSeekV4ModelId helper. The stream wrapper still keeps a runtime typeof model.id === "string" guard before calling the helper.

@hxy91819
hxy91819 force-pushed the fix/deepseek-v4-thinking-profile branch from 8fc2e0d to ef561a5 Compare April 30, 2026 15:22
@hxy91819
hxy91819 merged commit 797d574 into openclaw:main Apr 30, 2026
68 checks passed
@hxy91819

Copy link
Copy Markdown
Member

Merged via squash.

Thanks @ai-hpc!

@ai-hpc

ai-hpc commented Apr 30, 2026

Copy link
Copy Markdown
Member Author

Thanks. @hxy91819

steipete pushed a commit that referenced this pull request Apr 30, 2026
Merged via squash.

Prepared head SHA: ef561a5
Co-authored-by: ai-hpc <[email protected]>
Co-authored-by: hxy91819 <[email protected]>
Reviewed-by: @hxy91819
lxe pushed a commit to lxe/openclaw that referenced this pull request May 6, 2026
Merged via squash.

Prepared head SHA: ef561a5
Co-authored-by: ai-hpc <[email protected]>
Co-authored-by: hxy91819 <[email protected]>
Reviewed-by: @hxy91819
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
Merged via squash.

Prepared head SHA: ef561a5
Co-authored-by: ai-hpc <[email protected]>
Co-authored-by: hxy91819 <[email protected]>
Reviewed-by: @hxy91819
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
Merged via squash.

Prepared head SHA: ef561a5
Co-authored-by: ai-hpc <[email protected]>
Co-authored-by: hxy91819 <[email protected]>
Reviewed-by: @hxy91819
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
Merged via squash.

Prepared head SHA: ef561a5
Co-authored-by: ai-hpc <[email protected]>
Co-authored-by: hxy91819 <[email protected]>
Reviewed-by: @hxy91819
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
Merged via squash.

Prepared head SHA: ef561a5
Co-authored-by: ai-hpc <[email protected]>
Co-authored-by: hxy91819 <[email protected]>
Reviewed-by: @hxy91819
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation extensions: deepseek size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DeepSeek provider plugin missing resolveThinkingProfile — /think max/xhigh rejected on deepseek-v4-pro despite full backend support

2 participants