fix: clamp 'minimal' thinking level to 'low' for gpt-5.x models (#688)
gpt-5.x models (via Copilot/OpenAI/Azure) don't support 'minimal' as a reasoning effort level — they only accept 'none', 'low', 'medium', 'high', and 'xhigh'. Setting /thinking minimal with gpt-5.4 causes a 400 error. The openai-codex-responses provider already had this clamping, but the openai-responses and azure-openai-responses providers passed the value through unclamped. Add clampReasoningForModel() to both providers that maps 'minimal' to 'low' for gpt-5.x models, matching the existing behavior in openai-codex-responses. Fixes the bug portion of #688
This commit is contained in:
parent
a90aa0c8d6
commit
1a499aecb2
2 changed files with 24 additions and 2 deletions
|
|
@ -15,6 +15,16 @@ import { AssistantMessageEventStream } from "../utils/event-stream.js";
|
|||
import { convertResponsesMessages, convertResponsesTools, processResponsesStream } from "./openai-responses-shared.js";
|
||||
import { buildBaseOptions, clampReasoning } from "./simple-options.js";
|
||||
|
||||
/**
|
||||
* Clamp reasoning effort for models that don't support all levels.
|
||||
* gpt-5.x models don't support "minimal" — map to "low".
|
||||
*/
|
||||
function clampReasoningForModel(modelName: string, effort: string): string {
|
||||
const name = modelName.includes("/") ? modelName.split("/").pop()! : modelName;
|
||||
if (name.startsWith("gpt-5") && effort === "minimal") return "low";
|
||||
return effort;
|
||||
}
|
||||
|
||||
const DEFAULT_AZURE_API_VERSION = "v1";
|
||||
const AZURE_TOOL_CALL_PROVIDERS = new Set(["openai", "openai-codex", "opencode", "azure-openai-responses"]);
|
||||
|
||||
|
|
@ -234,8 +244,9 @@ function buildParams(
|
|||
|
||||
if (model.reasoning) {
|
||||
if (options?.reasoningEffort || options?.reasoningSummary) {
|
||||
const effort = clampReasoningForModel(model.name, options?.reasoningEffort || "medium") as typeof options.reasoningEffort;
|
||||
params.reasoning = {
|
||||
effort: options?.reasoningEffort || "medium",
|
||||
effort: effort || "medium",
|
||||
summary: options?.reasoningSummary || "auto",
|
||||
};
|
||||
params.include = ["reasoning.encrypted_content"];
|
||||
|
|
|
|||
|
|
@ -18,6 +18,16 @@ import { buildCopilotDynamicHeaders, hasCopilotVisionInput } from "./github-copi
|
|||
import { convertResponsesMessages, convertResponsesTools, processResponsesStream } from "./openai-responses-shared.js";
|
||||
import { buildBaseOptions, clampReasoning } from "./simple-options.js";
|
||||
|
||||
/**
|
||||
* Clamp reasoning effort for models that don't support all levels.
|
||||
* gpt-5.x models don't support "minimal" — map to "low".
|
||||
*/
|
||||
function clampReasoningForModel(modelName: string, effort: string): string {
|
||||
const name = modelName.includes("/") ? modelName.split("/").pop()! : modelName;
|
||||
if (name.startsWith("gpt-5") && effort === "minimal") return "low";
|
||||
return effort;
|
||||
}
|
||||
|
||||
const OPENAI_TOOL_CALL_PROVIDERS = new Set(["openai", "openai-codex", "opencode"]);
|
||||
|
||||
/**
|
||||
|
|
@ -215,8 +225,9 @@ function buildParams(model: Model<"openai-responses">, context: Context, options
|
|||
|
||||
if (model.reasoning) {
|
||||
if (options?.reasoningEffort || options?.reasoningSummary) {
|
||||
const effort = clampReasoningForModel(model.name, options?.reasoningEffort || "medium") as typeof options.reasoningEffort;
|
||||
params.reasoning = {
|
||||
effort: options?.reasoningEffort || "medium",
|
||||
effort: effort || "medium",
|
||||
summary: options?.reasoningSummary || "auto",
|
||||
};
|
||||
params.include = ["reasoning.encrypted_content"];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue