Merge pull request #5196 from earendil-works/fix/opencode-thinking-requests

fix(ai): handle OpenCode reasoning params
This commit is contained in:
Mario Zechner
2026-05-29 22:32:13 +02:00
committed by GitHub
7 changed files with 60 additions and 11 deletions

View File

@@ -995,7 +995,7 @@ describe("openai-completions tool_choice", () => {
expect(messages[0]).not.toHaveProperty("reasoning");
});
it("sends thinking none for OpenCode Go Kimi K2.6 when thinking is off", async () => {
it("sends thinking disabled for OpenCode Go Kimi K2.6 when thinking is off", async () => {
const model = getModel("opencode-go", "kimi-k2.6")!;
let payload: unknown;
@@ -1012,12 +1012,12 @@ describe("openai-completions tool_choice", () => {
},
).result();
const params = (payload ?? mockState.lastParams) as { thinking?: string; reasoning_effort?: string };
expect(params.thinking).toBe("none");
const params = (payload ?? mockState.lastParams) as { thinking?: unknown; reasoning_effort?: string };
expect(params.thinking).toEqual({ type: "disabled" });
expect(params.reasoning_effort).toBeUndefined();
});
it("sends thinking effort for OpenCode Go Kimi K2.6 when thinking is enabled", async () => {
it("sends thinking enabled for OpenCode Go Kimi K2.6 when thinking is enabled", async () => {
const model = getModel("opencode-go", "kimi-k2.6")!;
let payload: unknown;
@@ -1035,8 +1035,30 @@ describe("openai-completions tool_choice", () => {
},
).result();
const params = (payload ?? mockState.lastParams) as { thinking?: string; reasoning_effort?: string };
expect(params.thinking).toBe("high");
const params = (payload ?? mockState.lastParams) as { thinking?: unknown; reasoning_effort?: string };
expect(params.thinking).toEqual({ type: "enabled" });
expect(params.reasoning_effort).toBeUndefined();
});
it("omits reasoning effort for OpenCode Grok Build", async () => {
const model = getModel("opencode", "grok-build-0.1")!;
let payload: unknown;
await streamSimple(
model,
{
messages: [{ role: "user", content: "Hi", timestamp: Date.now() }],
},
{
apiKey: "test",
reasoning: "high",
onPayload: (params: unknown) => {
payload = params;
},
},
).result();
const params = (payload ?? mockState.lastParams) as { reasoning_effort?: string };
expect(params.reasoning_effort).toBeUndefined();
});

View File

@@ -56,6 +56,18 @@ describe("getSupportedThinkingLevels", () => {
expect(getSupportedThinkingLevels(model!)).toEqual(["off", "high", "xhigh"]);
});
it("includes only high plus off for OpenCode Go Kimi K2.6", () => {
const model = getModel("opencode-go", "kimi-k2.6");
expect(model).toBeDefined();
expect(getSupportedThinkingLevels(model!)).toEqual(["off", "high"]);
});
it("includes only high for OpenCode Grok Build", () => {
const model = getModel("opencode", "grok-build-0.1");
expect(model).toBeDefined();
expect(getSupportedThinkingLevels(model!)).toEqual(["high"]);
});
it("includes only high/xhigh plus off for DeepSeek V4 Flash on OpenRouter", () => {
const model = getModel("openrouter", "deepseek/deepseek-v4-flash");
expect(model).toBeDefined();