Skip to content

Commit 8dc5196

Browse files
committed
fix(openai): block Extra Body temperature on o-series Responses requests
The Responses request guard leaves requestBody.temperature absent for o1/o3/o4 models, so an openAiExtraBody temperature survived the final spread and reached models that reject the parameter outright. The Chat Completions o-series path owns temperature: undefined and suppresses that collision. Mirror it by explicitly deleting the merged temperature for o-series models, and cover the combination in the request-builder spec.
1 parent fbf1f23 commit 8dc5196

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

‎src/api/providers/utils/__tests__/openai-compatible-responses.spec.ts‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,22 @@ it.each(["o1", "o3", "o4-mini"])(
193193
},
194194
)
195195

196+
it.each([
197+
{ modelId: "o1", expected: undefined },
198+
{ modelId: "o3", expected: undefined },
199+
{ modelId: "o4-mini", expected: undefined },
200+
{ modelId: "gpt-5.1", expected: 0.4 },
201+
])("handles Extra Body temperature for model $modelId", ({ modelId, expected }) => {
202+
const body = buildResponsesRequest(
203+
makeInput({
204+
options: { openAiModelId: modelId },
205+
extraBody: { temperature: 0.4 },
206+
}),
207+
)
208+
if (expected === undefined) expect(body).not.toHaveProperty("temperature")
209+
else expect(body).toHaveProperty("temperature", expected)
210+
})
211+
196212
it("normalizes both history ID fields to the Responses call_id length limit", () => {
197213
// History recorded through another provider (e.g. Gemini) can carry tool
198214
// IDs longer than the Responses call_id limit; both fields must be

‎src/api/providers/utils/openai-compatible-responses.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,14 @@ export function buildResponsesRequest({
122122
}
123123
requestBody.parallel_tool_calls = metadata?.parallelToolCalls ?? true
124124
}
125-
return { ...extraBody, ...requestBody }
125+
const request = { ...extraBody, ...requestBody }
126+
// Mirror the Chat Completions o-series path, which owns
127+
// `temperature: undefined`: because the guard above leaves
128+
// requestBody.temperature absent for o-series models, an Extra Body
129+
// temperature would otherwise survive the spread and reach a model that
130+
// rejects the parameter outright. Remove it explicitly.
131+
if (isOSeriesModel) delete request.temperature
132+
return request
126133
}
127134

128135
/**

0 commit comments

Comments
 (0)