fix: only include verbosity parameter for models that support it (#7055)

Co-authored-by: Roo Code <roomote@roocode.com>
This commit is contained in:
roomote[bot] 2025-08-13 15:33:18 -04:00 committed by GitHub
parent 7ed833cb5d
commit 23afdfca03
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 64 additions and 2 deletions

View file

@ -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 },

View file

@ -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
}