diff --git a/src/api/providers/__tests__/openai-native.spec.ts b/src/api/providers/__tests__/openai-native.spec.ts index 1d76d387a9..0acdb6202e 100644 --- a/src/api/providers/__tests__/openai-native.spec.ts +++ b/src/api/providers/__tests__/openai-native.spec.ts @@ -258,6 +258,68 @@ describe("OpenAiNativeHandler", () => { }) }) + it("should not include verbosity parameter for models that don't support it", async () => { + // Test with gpt-4.1 which does NOT support verbosity + handler = new OpenAiNativeHandler({ + ...mockOptions, + apiModelId: "gpt-4.1", + verbosity: "high", // Set verbosity but it should be ignored + }) + + const stream = handler.createMessage(systemPrompt, messages) + const chunks: any[] = [] + for await (const chunk of stream) { + chunks.push(chunk) + } + + // Verify that verbosity is NOT included in the request + const callArgs = mockCreate.mock.calls[0][0] + expect(callArgs).not.toHaveProperty("verbosity") + expect(callArgs.model).toBe("gpt-4.1") + expect(callArgs.temperature).toBe(0) + expect(callArgs.stream).toBe(true) + }) + + it("should not include verbosity for gpt-4o models", async () => { + // Test with gpt-4o which does NOT support verbosity + handler = new OpenAiNativeHandler({ + ...mockOptions, + apiModelId: "gpt-4o", + verbosity: "medium", // Set verbosity but it should be ignored + }) + + const stream = handler.createMessage(systemPrompt, messages) + const chunks: any[] = [] + for await (const chunk of stream) { + chunks.push(chunk) + } + + // Verify that verbosity is NOT included in the request + const callArgs = mockCreate.mock.calls[0][0] + expect(callArgs).not.toHaveProperty("verbosity") + expect(callArgs.model).toBe("gpt-4o") + }) + + it("should not include verbosity for gpt-4.1-mini models", async () => { + // Test with gpt-4.1-mini which does NOT support verbosity + handler = new OpenAiNativeHandler({ + ...mockOptions, + apiModelId: "gpt-4.1-mini", + verbosity: "low", // Set verbosity but it should be ignored + }) + + const stream = handler.createMessage(systemPrompt, messages) + const chunks: any[] = [] + for await (const chunk of stream) { + chunks.push(chunk) + } + + // Verify that verbosity is NOT included in the request + const callArgs = mockCreate.mock.calls[0][0] + expect(callArgs).not.toHaveProperty("verbosity") + expect(callArgs.model).toBe("gpt-4.1-mini") + }) + it("should handle empty delta content", async () => { const mockStream = [ { choices: [{ delta: {} }], usage: null }, diff --git a/src/api/providers/openai-native.ts b/src/api/providers/openai-native.ts index 053af7f5e5..2ba8566963 100644 --- a/src/api/providers/openai-native.ts +++ b/src/api/providers/openai-native.ts @@ -194,8 +194,8 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio ...(reasoning && reasoning), } - // Add verbosity if supported - if (verbosity) { + // Add verbosity only if the model supports it + if (verbosity && model.info.supportsVerbosity) { params.verbosity = verbosity }