Skip to content

fix(opencode-go): enable xhigh/max thinking levels for DeepSeek V4 - #99618

Closed
34262315716 wants to merge 1 commit into
openclaw:mainfrom
34262315716:main
Closed

34262315716 wants to merge 1 commit into
openclaw:mainfrom
34262315716:main

Conversation

@34262315716

Copy link
Copy Markdown

Summary

Fixes: #99617

Problem

OpenClaw 的 thinking level 选择器对 opencode-go 的 DeepSeek V4 模型只能显示 minimum~high,xhigh/max 选项因为缺失 thinkingLevelMap 被 getSupportedThinkingLevels() 过滤掉。同时 stream wrapper 硬编码了 reasoning_effort 映射,不读取模型配置。

Changes

extensions/opencode-go/provider-catalog.ts

  • 为 deepseek-v4-pro 和 deepseek-v4-flash 新增 thinkingLevelMap 字段
  • 映射: minimal/low/medium → "high", high/xhigh/max → "max"
  • 定义本地 ProviderRuntimeModelWithThinkingLevelMap 类型确保类型安全

extensions/opencode-go/stream.ts

  • 用内联 streamWithPayloadPatch 逻辑替换 createDeepSeekV4OpenAICompatibleThinkingWrapper
  • 运行时读取 model.thinkingLevelMap;无 map 时回退到硬编码映射
  • 移除对共享 helper 的依赖,保持向后兼容

Verification

  • TypeScript 类型检查通过 (npx tsc -p extensions/opencode-go/tsconfig.json --noEmit)
  • 向后兼容:无 thinkingLevelMap 时行为与旧代码完全一致

Add thinkingLevelMap to DeepSeek V4 model catalog entries so
getSupportedThinkingLevels() allows xhigh and max selections.
Replace hardcoded createDeepSeekV4OpenAICompatibleThinkingWrapper
with inline streamWithPayloadPatch that reads thinkingLevelMap
from the model definition at runtime.

Closes the gap where DeepSeek V4 supports max reasoning_effort
but neither the catalog nor the wrapper exposed it.
@openclaw-barnacle openclaw-barnacle Bot added size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 3, 2026
@clawsweeper

clawsweeper Bot commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 3, 2026, 2:33 PM ET / 18:33 UTC.

Summary
The PR adds thinkingLevelMap entries for opencode-go DeepSeek V4 models and rewrites the opencode-go DeepSeek V4 stream wrapper to choose reasoning_effort from that map.

PR surface: Source +74. Total +74 across 2 files.

Reproducibility: yes. Source inspection shows current main lacks opencode-go DeepSeek V4 thinking metadata, and getSupportedThinkingLevels() filters xhigh and max unless those keys exist in the model's thinking map.

Review metrics: 1 noteworthy metric.

  • Provider thinking metadata: 2 maps added, 1 wrapper path replaced. These maps now control both advertised /think levels and outbound reasoning_effort, so compatibility depends on their exact values and wrapper ownership.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #99617
Summary: This PR is a candidate fix for the linked opencode-go DeepSeek V4 xhigh/max thinking-level issue, with one earlier same-author issue and one older draft PR covering the same root gap.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🧂 unranked krab
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • Map high below max and keep one shared DeepSeek V4 wrapper source.
  • [P1] Add focused opencode-go coverage for high, xhigh, max, and unrelated-model behavior.
  • [P1] Add redacted real opencode-go terminal output, payload/log capture, or status output, then update the PR body for a fresh ClawSweeper review.

Proof guidance:

  • [P1] Needs real behavior proof before merge: The PR body provides only a typecheck and compatibility claim; it needs after-fix real opencode-go proof such as redacted terminal output, payload/log capture, status output, or logs before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] Merging as-is would silently change existing opencode-go DeepSeek V4 /think high requests from provider reasoning_effort: "high" to "max", which can affect behavior, cost, and latency.
  • [P1] The stream rewrite creates a second source of truth for DeepSeek V4 disabled-thinking cleanup and replay backfill instead of reusing the shared SDK helper.
  • [P1] The branch is merge-conflicting, so maintainers cannot inspect the exact three-way merged opencode-go wrapper composition yet.
  • [P1] The contributor has not provided after-fix real opencode-go proof such as redacted terminal output, payload/log capture, or status output.

Maintainer options:

  1. Fix mapping and keep one wrapper source (recommended)
    Change the DeepSeek V4 opencode-go metadata so high stays below max, preserve or parameterize the shared DeepSeek V4 wrapper instead of inlining duplicate logic, and add focused tests.
  2. Accept a deliberate behavior upgrade
    Maintainers could intentionally accept high -> max only with explicit product approval, docs/proof for the behavior and cost tradeoff, and real opencode-go payload evidence.
  3. Pause behind the profile PR
    Because the older related PR has some real proof but is draft and conflicting, maintainers could pause this PR until one clean, tested opencode-go thinking-level fix is chosen.

Next step before merge

  • [P1] Human review is needed because the external PR lacks real behavior proof, is merge-conflicting, and needs a compatibility-sensitive wrapper/mapping decision before merge.

Security
Cleared: No concrete security or supply-chain concern is visible; the diff only changes provider TypeScript code and adds no dependencies, workflows, downloads, or secret handling.

Review findings

  • [P1] Keep high below max — extensions/opencode-go/provider-catalog.ts:38
  • [P1] Keep the shared DeepSeek wrapper — extensions/opencode-go/stream.ts:23
Review details

Best possible solution:

Expose xhigh and max for opencode-go DeepSeek V4 with provider-local metadata/profile coverage while preserving the shared DeepSeek V4 wrapper contract and lower-level high mapping.

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

Yes. Source inspection shows current main lacks opencode-go DeepSeek V4 thinking metadata, and getSupportedThinkingLevels() filters xhigh and max unless those keys exist in the model's thinking map.

Is this the best way to solve the issue?

No. The PR exposes the missing levels, but it is not the best fix because it changes high to max and duplicates shared DeepSeek V4 stream-wrapper behavior instead of preserving or extending the existing contract.

Full review comments:

  • [P1] Keep high below max — extensions/opencode-go/provider-catalog.ts:38
    This map is read by the new wrapper, so an existing /think high selection for either opencode-go DeepSeek V4 model would now send reasoning_effort: "max". Current docs and the shared DeepSeek V4 helper reserve max for xhigh/max, so high needs to stay mapped to high or remain handled by the shared helper.
    Confidence: 0.91
  • [P1] Keep the shared DeepSeek wrapper — extensions/opencode-go/stream.ts:23
    The inline streamWithPayloadPatch body recreates disabled-thinking cleanup and assistant reasoning_content backfill already exported by createDeepSeekV4OpenAICompatibleThinkingWrapper. Expose the missing levels without replacing that shared helper, or parameterize the helper so there is still one DeepSeek V4 wire-contract source.
    Confidence: 0.86

Overall correctness: patch is incorrect
Overall confidence: 0.89

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against df1452799b28.

Label changes

Label justifications:

  • P2: This is a bounded provider compatibility bugfix with limited blast radius, but the submitted patch has blocking correctness, proof, and merge-conflict gaps.
  • merge-risk: 🚨 compatibility: The PR changes how existing opencode-go DeepSeek V4 thinking selections are translated on the wire and replaces the current shared wrapper path.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: The PR body provides only a typecheck and compatibility claim; it needs after-fix real opencode-go proof such as redacted terminal output, payload/log capture, status output, or logs before merge. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +74. Total +74 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 2 82 8 +74
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 82 8 +74

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs extensions/opencode-go/index.test.ts.
  • [P1] node scripts/run-vitest.mjs src/plugin-sdk/provider-stream-shared.test.ts.
  • [P1] git diff --check.

What I checked:

  • Repository policy read: Root AGENTS.md and scoped extensions/AGENTS.md were read; the extension policy says bundled provider plugins should reuse shared SDK stream helpers before adding provider-local wrapper logic. (extensions/AGENTS.md:24, df1452799b28)
  • Current main lacks the needed opencode-go DeepSeek V4 thinking metadata: The two opencode-go DeepSeek V4 catalog rows are reasoning-capable and support reasoning_effort, but have no thinkingLevelMap entries on current main. (extensions/opencode-go/provider-catalog.ts:37, df1452799b28)
  • Current main filters extended thinking levels without map entries: getSupportedThinkingLevels() only advertises xhigh and max when the model's resolved thinking map has those keys, matching the source-level bug report. (src/llm/model-utils.ts:46, df1452799b28)
  • Shared DeepSeek V4 wrapper owns the current wire contract: The shared helper maps only xhigh and max to provider reasoning_effort: "max"; all lower enabled levels map to high, and the same helper owns disabled cleanup plus replay backfill. (src/plugin-sdk/provider-stream-shared.ts:481, df1452799b28)
  • Docs agree that lower DeepSeek V4 levels stay below max: The thinking docs say direct DeepSeek V4 exposes /think xhigh|max as max while lower non-off levels map to high. Public docs: docs/tools/thinking.md. (docs/tools/thinking.md:29, df1452799b28)
  • PR maps existing high to max: The PR-added maps set high: "max" for both opencode-go DeepSeek V4 entries, and the rewritten stream wrapper reads that map for outbound reasoning_effort. (extensions/opencode-go/provider-catalog.ts:38, 25bb674ba770)

Likely related people:

  • ImLukeF: PR metadata for Providers: add Opencode Go support #42313 shows this handle authored the original OpenCode Go provider support that introduced the affected provider area. (role: introduced provider surface; confidence: medium; commits: 7761e7626ffe; files: extensions/opencode-go/provider-catalog.ts, extensions/opencode-go/index.ts, docs/providers/opencode-go.md)
  • steipete: Recent history includes adding OpenCode Go DeepSeek V4 models and routing DeepSeek V4 through OpenAI transport on the affected catalog/stream path. (role: recent opencode-go behavior contributor; confidence: high; commits: 390be8138f28, afd6b5d6fce1, 669402b0b92e; files: extensions/opencode-go/provider-catalog.ts, extensions/opencode-go/stream.ts, extensions/opencode-go/reasoning-sanitizer.ts)
  • vincentkoc: Recent shared provider reasoning payload normalization and opencode catalog helper work touches the SDK/helper boundary this PR duplicates. (role: adjacent shared-helper contributor; confidence: medium; commits: 35bafea757fa, 66701d5a1e16, 4c15f1310bd5; files: src/plugin-sdk/provider-stream-shared.ts, extensions/opencode-go/provider-catalog.ts, extensions/opencode-go/index.ts)
  • zhang-guiping: Recent opencode-go stream completion/stalled-SSE work changed the wrapper chain that this PR rewrites. (role: recent stream-wrapper contributor; confidence: medium; commits: 769579bcf0c2, 09486e88b8f7; files: extensions/opencode-go/stream.ts, extensions/opencode-go/stream-termination.ts, extensions/opencode-go/stream-termination.test.ts)
  • ai-hpc: Authored the direct DeepSeek V4 max thinking-profile fix, which is the closest sibling provider pattern for exposing DeepSeek V4 xhigh and max. (role: adjacent thinking-profile contributor; confidence: medium; commits: 007023e8a4bd; files: extensions/deepseek/index.ts, extensions/deepseek/models.ts, extensions/deepseek/index.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jul 3, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 18, 2026
@clawsweeper

clawsweeper Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(opencode-go): enable xhigh/max thinking levels for DeepSeek V4 This is item 1/1 in the current shard. Shard 8/10.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@openclaw-barnacle

Copy link
Copy Markdown

Closing due to inactivity.
If you believe this PR should be revived, post in #clawtributors on Discord to talk to a maintainer.
That channel is the escape hatch for high-quality PRs that get auto-closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: opencode-go merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S stale Marked as stale due to inactivity status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

opencode-go: DeepSeek V4 xhigh/max thinking levels not selectable

1 participant