Skip to content

Commit 059fe6f

Browse files
committed
docs: clarify why minimal reasoning effort is filtered for OpenAI SDK
The OpenAI SDK TypeScript definitions do not include "minimal" as a valid reasoning_effort value, even though GPT-5 via OpenRouter supports it. This commit: - Adds documentation explaining the SDK limitation - Updates tests to reflect that OpenAI filters out "minimal" while OpenRouter preserves it - Ensures consistency in how different providers handle reasoning parameters The original PR correctly implements passing "minimal" through for OpenRouter. This change only adds clarity about why the handling differs between providers.
1 parent d57bb82 commit 059fe6f

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

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

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

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

536536
efforts.forEach((effort) => {
537537
const modelWithEffort: ModelInfo = {
@@ -550,12 +550,11 @@ describe("reasoning.ts", () => {
550550
reasoningEffort: effort,
551551
}
552552
const result = getOpenAiReasoning(options)
553-
// All effort values including "minimal" should be passed through for OpenAI (e.g., GPT-5)
554553
expect(result).toEqual({ reasoning_effort: effort })
555554
})
556555
})
557556

558-
it("should handle minimal reasoning effort specifically", () => {
557+
it("should filter out minimal reasoning effort for OpenAI SDK compatibility", () => {
559558
const modelWithEffort: ModelInfo = {
560559
...baseModel,
561560
supportsReasoningEffort: true,
@@ -574,8 +573,9 @@ describe("reasoning.ts", () => {
574573

575574
const result = getOpenAiReasoning(options)
576575

577-
// "minimal" should be passed through for OpenAI models like GPT-5
578-
expect(result).toEqual({ reasoning_effort: "minimal" })
576+
// "minimal" is filtered out for OpenAI SDK compatibility
577+
// OpenRouter handles "minimal" correctly in its own function
578+
expect(result).toBeUndefined()
579579
})
580580

581581
it("should not be affected by reasoningBudget parameter", () => {

src/api/transform/reasoning.ts

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

65-
// If model has reasoning effort capability, return object with the effort
66-
// OpenAI models (including GPT-5) support all effort levels including "minimal"
65+
// Note: The OpenAI SDK doesn't include "minimal" in its type definitions,
66+
// but GPT-5 via OpenRouter does support it. Since this function is for
67+
// direct OpenAI API usage (not OpenRouter), we filter out "minimal" here.
68+
// OpenRouter handles "minimal" correctly in getOpenRouterReasoning.
69+
if (reasoningEffort === "minimal") {
70+
return undefined
71+
}
72+
6773
return { reasoning_effort: reasoningEffort }
6874
}
6975

0 commit comments

Comments
 (0)