From b7bb92f53f2cd2451f4a9b0ea15255418eae6acd Mon Sep 17 00:00:00 2001 From: Roo Code Date: Sat, 8 Nov 2025 18:34:01 +0000 Subject: [PATCH] refactor: use includes() for DeepSeek V3.1 Terminus model check to support variants --- .../providers/__tests__/openrouter.spec.ts | 49 +++++++++++++++++++ src/api/providers/openrouter.ts | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/src/api/providers/__tests__/openrouter.spec.ts b/src/api/providers/__tests__/openrouter.spec.ts index 4bd6f1798e..2b961c6055 100644 --- a/src/api/providers/__tests__/openrouter.spec.ts +++ b/src/api/providers/__tests__/openrouter.spec.ts @@ -62,6 +62,17 @@ vitest.mock("../fetchers/modelCache", () => ({ supportsReasoningEffort: true, supportedReasoningEfforts: ["low", "medium", "high"], }, + "deepseek/deepseek-v3.1-terminus:exacto": { + maxTokens: 8192, + contextWindow: 128000, + supportsImages: false, + supportsPromptCache: false, + inputPrice: 0.3, + outputPrice: 1.2, + description: "DeepSeek V3.1 Terminus Exacto", + supportsReasoningEffort: true, + supportedReasoningEfforts: ["low", "medium", "high"], + }, }) }), })) @@ -480,5 +491,43 @@ describe("OpenRouterHandler", () => { }), ) }) + + it("should handle DeepSeek V3.1 Terminus exacto variant with chat_template_kwargs", async () => { + const handler = new OpenRouterHandler({ + openRouterApiKey: "test-key", + openRouterModelId: "deepseek/deepseek-v3.1-terminus:exacto", + reasoningEffort: "medium", + }) + + const mockStream = { + async *[Symbol.asyncIterator]() { + yield { + id: "test-id", + choices: [{ delta: { content: "test response" } }], + } + }, + } + + const mockCreate = vitest.fn().mockResolvedValue(mockStream) + ;(OpenAI as any).prototype.chat = { + completions: { create: mockCreate }, + } as any + + await handler.createMessage("test", []).next() + + // Should include chat_template_kwargs with thinking:true for exacto variant + expect(mockCreate).toHaveBeenCalledWith( + expect.objectContaining({ + model: "deepseek/deepseek-v3.1-terminus:exacto", + chat_template_kwargs: { thinking: true }, + }), + ) + // Ensure reasoning parameter is NOT included + expect(mockCreate).not.toHaveBeenCalledWith( + expect.objectContaining({ + reasoning: expect.anything(), + }), + ) + }) }) }) diff --git a/src/api/providers/openrouter.ts b/src/api/providers/openrouter.ts index 7d5cc1a251..d0b0e89cd2 100644 --- a/src/api/providers/openrouter.ts +++ b/src/api/providers/openrouter.ts @@ -113,7 +113,7 @@ export class OpenRouterHandler extends BaseProvider implements SingleCompletionH chatTemplateKwargs: { thinking?: boolean } | undefined finalReasoning: OpenRouterReasoningParams | undefined } { - if (!modelId.startsWith("deepseek/deepseek-v3.1-terminus")) { + if (!modelId.includes("deepseek-v3.1-terminus")) { return { chatTemplateKwargs: undefined, finalReasoning: reasoning } }