Skip to content

fix: remove temperature parameter for GPT-5 models #6966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
9 changes: 6 additions & 3 deletions src/api/providers/__tests__/openai-native.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,8 @@ describe("OpenAiNativeHandler", () => {
expect(body1).toContain('"effort":"medium"')
expect(body1).toContain('"summary":"auto"')
expect(body1).toContain('"verbosity":"medium"')
expect(body1).toContain('"temperature":1')
// GPT-5 no longer supports temperature parameter
expect(body1).not.toContain('"temperature"')
expect(body1).toContain('"max_output_tokens"')

// Verify the streamed content
Expand Down Expand Up @@ -856,7 +857,8 @@ describe("OpenAiNativeHandler", () => {
expect(body2).toContain('"effort":"low"')
expect(body2).toContain('"summary":"auto"')
expect(body2).toContain('"verbosity":"medium"')
expect(body2).toContain('"temperature":1')
// GPT-5 no longer supports temperature parameter
expect(body2).not.toContain('"temperature"')
expect(body2).toContain('"max_output_tokens"')

// Clean up
Expand Down Expand Up @@ -906,7 +908,8 @@ describe("OpenAiNativeHandler", () => {
expect(body3).toContain('"effort":"minimal"')
expect(body3).toContain('"summary":"auto"')
expect(body3).toContain('"verbosity":"high"')
expect(body3).toContain('"temperature":1')
// GPT-5 no longer supports temperature parameter
expect(body3).not.toContain('"temperature"')
expect(body3).toContain('"max_output_tokens"')

// Clean up
Expand Down
4 changes: 2 additions & 2 deletions src/api/providers/openai-native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
stream: boolean
reasoning?: { effort: ReasoningEffortWithMinimal; summary?: "auto" }
text?: { verbosity: VerbosityLevel }
temperature?: number
// temperature parameter removed - GPT-5 no longer supports it
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor style inconsistency: This comment uses a different format than the line comment on line 292. Could we standardize on one comment style for consistency?

max_output_tokens?: number
previous_response_id?: string
}
Expand All @@ -289,7 +289,7 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
},
}),
text: { verbosity: (verbosity || "medium") as VerbosityLevel },
temperature: this.options.modelTemperature ?? GPT5_DEFAULT_TEMPERATURE,
// GPT-5 no longer supports temperature parameter
// Explicitly include the calculated max output tokens for GPT‑5.
// Use the per-request reserved output computed by Roo (params.maxTokens from getModelParams).
...(model.maxTokens ? { max_output_tokens: model.maxTokens } : {}),
Expand Down
4 changes: 2 additions & 2 deletions src/api/transform/model-params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,9 @@ export function getModelParams({
reasoning: getAnthropicReasoning({ model, reasoningBudget, reasoningEffort, settings }),
}
} else if (format === "openai") {
// Special case for o1 and o3-mini, which don't support temperature.
// Special case for o1, o3-mini, and GPT-5 models, which don't support temperature.
// TODO: Add a `supportsTemperature` field to the model info.
if (modelId.startsWith("o1") || modelId.startsWith("o3-mini")) {
if (modelId.startsWith("o1") || modelId.startsWith("o3-mini") || modelId.startsWith("gpt-5")) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The existing TODO mentions adding a supportsTemperature field. Since we're now handling GPT-5 alongside o1 and o3-mini, would it be worth prioritizing this refactor to make the temperature support more explicit in the model definitions?

params.temperature = undefined
}

Expand Down
Loading