diff --git a/src/adapters/openai-chat.ts b/src/adapters/openai-chat.ts index d98d8c7e5fc..0e463c65f54 100644 --- a/src/adapters/openai-chat.ts +++ b/src/adapters/openai-chat.ts @@ -349,7 +349,9 @@ function ensureZenRootObjectSchema(schema: unknown): Record { } function shouldSanitizeZenToolParameters(provider: OcxProviderConfig): boolean { - return provider.baseUrl.replace(/\/+$/, "") === "https://opencode.ai/zen/v1"; + const baseUrl = provider.baseUrl.replace(/\/+$/, ""); + return baseUrl === "https://opencode.ai/zen/v1" + || baseUrl === "https://opencode.ai/zen/go/v1"; } const XAI_SCHEMA_BASE_URLS = new Set(["api.x.ai", "cli-chat-proxy.grok.com"]); diff --git a/tests/opencode-go-deepseek.test.ts b/tests/opencode-go-deepseek.test.ts index c8a0621652c..018405e1e70 100644 --- a/tests/opencode-go-deepseek.test.ts +++ b/tests/opencode-go-deepseek.test.ts @@ -53,6 +53,52 @@ function buildToolCallBody(modelId: string, reasoning: string): { } describe("opencode-go DeepSeek V4 thinking mode", () => { + test("normalizes Desktop-style root composition schemas for Console Go", () => { + const route = routeModel(configFor("deepseek-v4-pro"), "opencode-go/deepseek-v4-pro"); + const req = createOpenAIChatAdapter(route.provider).buildRequest({ + modelId: route.modelId, + context: { + messages: [{ role: "user", content: "inspect the repo", timestamp: 0 }], + tools: [{ + name: "automation_update", + description: "Update an automation", + parameters: { + oneOf: [ + { + type: "object", + properties: { mode: { $ref: "#/$defs/mode" } }, + required: ["mode"], + }, + { + type: "object", + properties: { id: { type: "string" } }, + required: ["id"], + }, + ], + $defs: { mode: { type: "string", enum: ["create", "update"] } }, + }, + }], + }, + stream: true, + options: { reasoning: "high" }, + }); + + const body = JSON.parse(req.body as string) as { + tools: Array<{ function: { parameters: Record } }>; + }; + const parameters = body.tools[0].function.parameters; + + expect(parameters.type).toBe("object"); + expect(parameters.oneOf).toBeUndefined(); + expect(parameters.properties).toEqual({ + mode: { $ref: "#/$defs/mode" }, + id: { type: "string" }, + }); + expect(parameters.$defs).toEqual({ + mode: { type: "string", enum: ["create", "update"] }, + }); + }); + test.each(["deepseek-v4-flash", "deepseek-v4-pro"])( "%s replays tool-call reasoning and maps Codex efforts", modelId => {