Skip to content

Commit 23afdfc

Browse files
fix: only include verbosity parameter for models that support it (#7055)
Co-authored-by: Roo Code <[email protected]>
1 parent 7ed833c commit 23afdfc

File tree

2 files changed

+64
-2
lines changed

2 files changed

+64
-2
lines changed

src/api/providers/__tests__/openai-native.spec.ts

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,68 @@ describe("OpenAiNativeHandler", () => {
258258
})
259259
})
260260

261+
it("should not include verbosity parameter for models that don't support it", async () => {
262+
// Test with gpt-4.1 which does NOT support verbosity
263+
handler = new OpenAiNativeHandler({
264+
...mockOptions,
265+
apiModelId: "gpt-4.1",
266+
verbosity: "high", // Set verbosity but it should be ignored
267+
})
268+
269+
const stream = handler.createMessage(systemPrompt, messages)
270+
const chunks: any[] = []
271+
for await (const chunk of stream) {
272+
chunks.push(chunk)
273+
}
274+
275+
// Verify that verbosity is NOT included in the request
276+
const callArgs = mockCreate.mock.calls[0][0]
277+
expect(callArgs).not.toHaveProperty("verbosity")
278+
expect(callArgs.model).toBe("gpt-4.1")
279+
expect(callArgs.temperature).toBe(0)
280+
expect(callArgs.stream).toBe(true)
281+
})
282+
283+
it("should not include verbosity for gpt-4o models", async () => {
284+
// Test with gpt-4o which does NOT support verbosity
285+
handler = new OpenAiNativeHandler({
286+
...mockOptions,
287+
apiModelId: "gpt-4o",
288+
verbosity: "medium", // Set verbosity but it should be ignored
289+
})
290+
291+
const stream = handler.createMessage(systemPrompt, messages)
292+
const chunks: any[] = []
293+
for await (const chunk of stream) {
294+
chunks.push(chunk)
295+
}
296+
297+
// Verify that verbosity is NOT included in the request
298+
const callArgs = mockCreate.mock.calls[0][0]
299+
expect(callArgs).not.toHaveProperty("verbosity")
300+
expect(callArgs.model).toBe("gpt-4o")
301+
})
302+
303+
it("should not include verbosity for gpt-4.1-mini models", async () => {
304+
// Test with gpt-4.1-mini which does NOT support verbosity
305+
handler = new OpenAiNativeHandler({
306+
...mockOptions,
307+
apiModelId: "gpt-4.1-mini",
308+
verbosity: "low", // Set verbosity but it should be ignored
309+
})
310+
311+
const stream = handler.createMessage(systemPrompt, messages)
312+
const chunks: any[] = []
313+
for await (const chunk of stream) {
314+
chunks.push(chunk)
315+
}
316+
317+
// Verify that verbosity is NOT included in the request
318+
const callArgs = mockCreate.mock.calls[0][0]
319+
expect(callArgs).not.toHaveProperty("verbosity")
320+
expect(callArgs.model).toBe("gpt-4.1-mini")
321+
})
322+
261323
it("should handle empty delta content", async () => {
262324
const mockStream = [
263325
{ choices: [{ delta: {} }], usage: null },

src/api/providers/openai-native.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,8 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
194194
...(reasoning && reasoning),
195195
}
196196

197-
// Add verbosity if supported
198-
if (verbosity) {
197+
// Add verbosity only if the model supports it
198+
if (verbosity && model.info.supportsVerbosity) {
199199
params.verbosity = verbosity
200200
}
201201

0 commit comments

Comments
 (0)