Skip to content

Commit d57bb82

Browse files
committed
fix: ensure OpenAI reasoning effort supports minimal value
- Remove special case that filtered out "minimal" reasoning effort for OpenAI - OpenAI models (including GPT-5) support all effort levels including "minimal" - Add comprehensive tests for all reasoning effort values including "minimal" - Align OpenAI behavior with OpenRouter which correctly passes through "minimal"
1 parent 6b159c9 commit d57bb82

File tree

2 files changed

+38
-9
lines changed

2 files changed

+38
-9
lines changed

src/api/transform/__tests__/reasoning.spec.ts

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -530,21 +530,54 @@ describe("reasoning.ts", () => {
530530
expect(result).toEqual({ reasoning_effort: undefined })
531531
})
532532

533-
it("should handle all reasoning effort values", () => {
534-
const efforts: Array<"low" | "medium" | "high"> = ["low", "medium", "high"]
533+
it("should handle all reasoning effort values including minimal", () => {
534+
const efforts: Array<ReasoningEffortWithMinimal> = ["minimal", "low", "medium", "high"]
535535

536536
efforts.forEach((effort) => {
537537
const modelWithEffort: ModelInfo = {
538538
...baseModel,
539+
supportsReasoningEffort: true,
540+
}
541+
542+
const settingsWithEffort: ProviderSettings = {
539543
reasoningEffort: effort,
540544
}
541545

542-
const options = { ...baseOptions, model: modelWithEffort, reasoningEffort: effort }
546+
const options = {
547+
...baseOptions,
548+
model: modelWithEffort,
549+
settings: settingsWithEffort,
550+
reasoningEffort: effort,
551+
}
543552
const result = getOpenAiReasoning(options)
553+
// All effort values including "minimal" should be passed through for OpenAI (e.g., GPT-5)
544554
expect(result).toEqual({ reasoning_effort: effort })
545555
})
546556
})
547557

558+
it("should handle minimal reasoning effort specifically", () => {
559+
const modelWithEffort: ModelInfo = {
560+
...baseModel,
561+
supportsReasoningEffort: true,
562+
}
563+
564+
const settingsWithMinimal: ProviderSettings = {
565+
reasoningEffort: "minimal",
566+
}
567+
568+
const options = {
569+
...baseOptions,
570+
model: modelWithEffort,
571+
settings: settingsWithMinimal,
572+
reasoningEffort: "minimal" as ReasoningEffortWithMinimal,
573+
}
574+
575+
const result = getOpenAiReasoning(options)
576+
577+
// "minimal" should be passed through for OpenAI models like GPT-5
578+
expect(result).toEqual({ reasoning_effort: "minimal" })
579+
})
580+
548581
it("should not be affected by reasoningBudget parameter", () => {
549582
const modelWithEffort: ModelInfo = {
550583
...baseModel,

src/api/transform/reasoning.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,8 @@ export const getOpenAiReasoning = ({
6262
return undefined
6363
}
6464

65-
// If model has reasoning effort capability, return object even if effort is undefined
66-
// This preserves the reasoning_effort field in the API call
67-
if (reasoningEffort === "minimal") {
68-
return undefined
69-
}
70-
65+
// If model has reasoning effort capability, return object with the effort
66+
// OpenAI models (including GPT-5) support all effort levels including "minimal"
7167
return { reasoning_effort: reasoningEffort }
7268
}
7369

0 commit comments

Comments
 (0)