Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/api/providers/__tests__/openai.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,27 @@ describe("OpenAiHandler", () => {
expect(callArgs.reasoning_effort).toBe("high")
})

it("should pass through max reasoning_effort when configured by an OpenAI-compatible model", async () => {
const reasoningOptions: ApiHandlerOptions = {
...mockOptions,
enableReasoningEffort: true,
openAiCustomModelInfo: {
contextWindow: 128_000,
supportsPromptCache: false,
supportsReasoningEffort: ["low", "medium", "high", "xhigh", "max"],
reasoningEffort: "max",
},
}
const reasoningHandler = new OpenAiHandler(reasoningOptions)
const stream = reasoningHandler.createMessage(systemPrompt, messages)
for await (const _chunk of stream) {
}

expect(mockCreate).toHaveBeenCalled()
const callArgs = mockCreate.mock.calls[0][0]
expect(callArgs.reasoning_effort).toBe("max")
})

it("should not include reasoning_effort when reasoning effort is disabled", async () => {
const noReasoningOptions: ApiHandlerOptions = {
...mockOptions,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { VSCodeButton, VSCodeTextField } from "@vscode/webview-ui-toolkit/react"
import {
type ProviderSettings,
type ModelInfo,
type ReasoningEffort,
type ReasoningEffortExtended,
type OrganizationAllowList,
type ExtensionMessage,
azureOpenAiDefaultApiVersion,
Expand Down Expand Up @@ -266,13 +266,13 @@ export const OpenAICompatible = ({

setApiConfigurationField("openAiCustomModelInfo", {
...openAiCustomModelInfo,
reasoningEffort: value as ReasoningEffort,
reasoningEffort: value as ReasoningEffortExtended,
})
}
}}
modelInfo={{
...(apiConfiguration.openAiCustomModelInfo || openAiModelInfoSaneDefaults),
supportsReasoningEffort: ["low", "medium", "high", "xhigh"],
supportsReasoningEffort: ["low", "medium", "high", "xhigh", "max"],
}}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,13 @@ vi.mock("../../R1FormatSetting", () => ({
R1FormatSetting: () => <div data-testid="r1-format-setting">R1 Format Setting</div>,
}))

const { mockThinkingBudget } = vi.hoisted(() => ({ mockThinkingBudget: vi.fn() }))

vi.mock("../../ThinkingBudget", () => ({
ThinkingBudget: () => <div data-testid="thinking-budget">Thinking Budget</div>,
ThinkingBudget: (props: any) => {
mockThinkingBudget(props)
return <div data-testid="thinking-budget">Thinking Budget</div>
},
}))

// Mock react-use
Expand Down Expand Up @@ -312,4 +317,39 @@ describe("OpenAICompatible Component - includeMaxTokens checkbox", () => {
expect(description).toHaveClass("text-sm", "text-vscode-descriptionForeground", "ml-6")
})
})
describe("reasoning effort", () => {
it("should expose and persist the max reasoning-effort value", () => {
const apiConfiguration: Partial<ProviderSettings> = {
enableReasoningEffort: true,
openAiCustomModelInfo: {
contextWindow: 128_000,
supportsPromptCache: false,
},
}

render(
<OpenAICompatible
apiConfiguration={apiConfiguration as ProviderSettings}
setApiConfigurationField={mockSetApiConfigurationField}
organizationAllowList={mockOrganizationAllowList}
/>,
)

const thinkingBudgetProps = mockThinkingBudget.mock.calls[0][0]
expect(thinkingBudgetProps.modelInfo.supportsReasoningEffort).toEqual([
"low",
"medium",
"high",
"xhigh",
"max",
])

thinkingBudgetProps.setApiConfigurationField("reasoningEffort", "max")

expect(mockSetApiConfigurationField).toHaveBeenCalledWith("openAiCustomModelInfo", {
...apiConfiguration.openAiCustomModelInfo,
reasoningEffort: "max",
})
})
})
})
Loading