mirror of
https://github.com/hanzoai/opencode-openai-codex-auth.git
synced 2026-09-24 17:01:02 +00:00
fix: Normalize 'minimal' to 'low' for gpt-5-codex
Codex CLI does not provide a 'minimal' reasoning effort preset for gpt-5-codex (only low/medium/high - see model_presets.rs:20-40). When users configure reasoningEffort: 'minimal' for gpt-5-codex, normalize it to 'low' to prevent unsupported configuration. - Add validation in getReasoningConfig() to detect and normalize - Add test case to verify normalization works correctly - Prevents potential errors when backend receives unsupported effort level Addresses feedback from GPT-5 Codex code review.
This commit is contained in:
@@ -48,13 +48,23 @@ export function getModelConfig(modelName, userConfig = {}) {
|
||||
export function getReasoningConfig(originalModel, userConfig = {}) {
|
||||
const isLightweight =
|
||||
originalModel?.includes("nano") || originalModel?.includes("mini");
|
||||
const isCodex = originalModel?.includes("codex");
|
||||
|
||||
// Default based on model type (Codex CLI defaults)
|
||||
const defaultEffort = isLightweight ? "minimal" : "medium";
|
||||
|
||||
// Get user-requested effort
|
||||
let effort = userConfig.reasoningEffort || defaultEffort;
|
||||
|
||||
// Normalize "minimal" to "low" for gpt-5-codex
|
||||
// Codex CLI does not provide a "minimal" preset for gpt-5-codex
|
||||
// (only low/medium/high - see model_presets.rs:20-40)
|
||||
if (isCodex && effort === "minimal") {
|
||||
effort = "low";
|
||||
}
|
||||
|
||||
return {
|
||||
// User config takes precedence, otherwise use defaults
|
||||
effort: userConfig.reasoningEffort || defaultEffort,
|
||||
effort,
|
||||
summary: userConfig.reasoningSummary || "auto", // Changed from "detailed" to match Codex CLI
|
||||
};
|
||||
}
|
||||
|
||||
+14
-1
@@ -87,9 +87,22 @@ console.log("Test 5: Lightweight model (gpt-5-nano)");
|
||||
const nanoReasoning = getReasoningConfig("gpt-5-nano", {});
|
||||
console.log("Nano reasoning:", nanoReasoning);
|
||||
console.log("Expected: effort='minimal' (lightweight default), summary='auto'");
|
||||
console.log("✓ Pass:",
|
||||
console.log("✓ Pass:",
|
||||
nanoReasoning.effort === "minimal" &&
|
||||
nanoReasoning.summary === "auto"
|
||||
);
|
||||
console.log("\n");
|
||||
|
||||
// Test 6: Normalize "minimal" to "low" for gpt-5-codex
|
||||
console.log("Test 6: Normalize minimal→low for gpt-5-codex (Codex CLI doesn't support minimal)");
|
||||
const codexMinimalConfig = { reasoningEffort: "minimal" };
|
||||
const codexMinimalReasoning = getReasoningConfig("gpt-5-codex", codexMinimalConfig);
|
||||
console.log("Config:", codexMinimalConfig);
|
||||
console.log("Reasoning result:", codexMinimalReasoning);
|
||||
console.log("Expected: effort='low' (normalized from minimal), summary='auto'");
|
||||
console.log("✓ Pass:",
|
||||
codexMinimalReasoning.effort === "low" &&
|
||||
codexMinimalReasoning.summary === "auto"
|
||||
);
|
||||
|
||||
console.log("\n=== All Tests Complete ===");
|
||||
|
||||
Reference in New Issue
Block a user