-
Notifications
You must be signed in to change notification settings - Fork 640
fix(providers): replay DeepSeek reasoning for opencode-zen (#994) #1068
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Wibias
merged 2 commits into
lidge-jun:dev
from
justjxke:fix/opencode-zen-reasoning-replay
Aug 6, 2026
+118
−9
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,104 @@ | ||
| import { describe, expect, test } from "bun:test"; | ||
| import { createOpenAIChatAdapter } from "../src/adapters/openai-chat"; | ||
| import { routeModel } from "../src/router"; | ||
| import type { OcxConfig } from "../src/types"; | ||
|
|
||
| function configFor(modelId: string): OcxConfig { | ||
| return { | ||
| port: 10110, | ||
| defaultProvider: "opencode-zen", | ||
| providers: { | ||
| "opencode-zen": { | ||
| adapter: "openai-chat", | ||
| baseUrl: "https://opencode.ai/zen/v1", | ||
| apiKey: "key", | ||
| models: [modelId], | ||
| }, | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| function buildToolCallBody(modelId: string, reasoning?: string): { | ||
| reasoning_effort?: string; | ||
| messages: Record<string, unknown>[]; | ||
| } { | ||
| const route = routeModel(configFor(modelId), `opencode-zen/${modelId}`); | ||
| const req = createOpenAIChatAdapter(route.provider).buildRequest({ | ||
| modelId: route.modelId, | ||
| context: { | ||
| messages: [ | ||
| { role: "user", content: "inspect the repo", timestamp: 0 }, | ||
| { role: "assistant", timestamp: 1, content: [ | ||
| { type: "thinking", thinking: "I need to inspect files before answering." }, | ||
| { type: "toolCall", id: "call_1", name: "read_file", arguments: { path: "README.md" } }, | ||
| ] }, | ||
| { | ||
| role: "toolResult", | ||
| toolCallId: "call_1", | ||
| toolName: "read_file", | ||
| content: "contents", | ||
| isError: false, | ||
| timestamp: 2, | ||
| }, | ||
| ], | ||
| }, | ||
| stream: true, | ||
| options: { reasoning: reasoning ?? "max" }, | ||
| }); | ||
|
|
||
| return JSON.parse(req.body as string) as { | ||
| reasoning_effort?: string; | ||
| messages: Record<string, unknown>[]; | ||
| }; | ||
| } | ||
|
|
||
| describe("opencode-zen DeepSeek thinking mode", () => { | ||
| test.each(["deepseek-v4-flash-free", "deepseek-v4-flash", "deepseek-v4-pro"])( | ||
| "%s replays tool-call reasoning_content and maps Codex efforts (issue #950/#994)", | ||
| modelId => { | ||
| const body = buildToolCallBody(modelId, "xhigh"); | ||
|
|
||
| const expectedEffort = modelId.includes("flash") ? "high" : "max"; | ||
| expect(body.reasoning_effort).toBe(expectedEffort); | ||
| expect(body.messages[1].reasoning_content).toBe("I need to inspect files before answering."); | ||
| expect(body.messages[1]).toMatchObject({ | ||
| role: "assistant", | ||
| content: "", | ||
| tool_calls: [{ | ||
| id: "call_1", | ||
| type: "function", | ||
| function: { name: "read_file", arguments: JSON.stringify({ path: "README.md" }) }, | ||
| }], | ||
| }); | ||
| }, | ||
| ); | ||
|
|
||
| test("non-DeepSeek opencode-zen models do not replay reasoning_content", () => { | ||
| const body = buildToolCallBody("minimax-m2.7"); | ||
|
|
||
| expect(body.messages[1].reasoning_content).toBeUndefined(); | ||
| expect(body.messages[1]).toHaveProperty("tool_calls"); | ||
| }); | ||
|
justjxke marked this conversation as resolved.
|
||
|
|
||
| test.each(["deepseek-v4-flash-free", "deepseek-v4-flash", "deepseek-v4-pro"])( | ||
| "%s is listed in opencode-zen noVisionModels for the vision sidecar", | ||
| modelId => { | ||
| const route = routeModel(configFor(modelId), `opencode-zen/${modelId}`); | ||
|
|
||
| expect(route.provider.noVisionModels).toContain(modelId); | ||
| }, | ||
| ); | ||
|
|
||
| test("Zen text-only free models (measured #1043) stay in noVisionModels", () => { | ||
| const route = routeModel(configFor("big-pickle"), "opencode-zen/big-pickle"); | ||
|
|
||
| expect(route.provider.noVisionModels).toContain("big-pickle"); | ||
| }); | ||
|
|
||
|
|
||
| test("non-DeepSeek opencode-zen models stay out of noVisionModels", () => { | ||
| const route = routeModel(configFor("minimax-m2.7"), "opencode-zen/minimax-m2.7"); | ||
|
|
||
| expect(route.provider.noVisionModels).not.toContain("minimax-m2.7"); | ||
| }); | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These new
opencode-zencalls todeepseekThinkingEffortsFor/deepseekReasoningMapForput three more model ids under the shared Flash-vs-Pro substring classifier, buttests/provider-registry-parity.test.ts’s “every DeepSeek V4 entry…” matrix still omits this provider. That matrix is the existing guard for every registry id that uses the classifier; without the Zen cases, a future Zen-specific id typo/name change could be mis-advertised without failing the parity test, so please add the threeopencode-zenmodels there.AGENTS.md reference: src/AGENTS.md:L22-L26
Useful? React with 👍 / 👎.