feat(thinking): normalize effort levels in adaptive thinking requests to prevent validation errors

This commit is contained in:
hkfires
2026-03-03 15:10:47 +08:00
parent 0452b869e8
commit ce87714ef1
7 changed files with 40 additions and 39 deletions

View File

@@ -232,19 +232,14 @@ func ConvertClaudeRequestToCodex(modelName string, inputRawJSON []byte, _ bool)
}
case "adaptive", "auto":
// Adaptive thinking can carry an explicit effort in output_config.effort (Claude 4.6).
// Preserve it when present; otherwise keep the previous "max capacity" sentinel.
// Pass through directly; ApplyThinking handles clamping to target model's levels.
effort := ""
if v := rootResult.Get("output_config.effort"); v.Exists() && v.Type == gjson.String {
effort = strings.ToLower(strings.TrimSpace(v.String()))
}
switch effort {
case "minimal", "low", "medium", "high":
if effort != "" {
reasoningEffort = effort
case "max":
reasoningEffort = string(thinking.LevelXHigh)
default:
// Keep adaptive/auto as a high level sentinel; ApplyThinking resolves it
// to model-specific max capability.
} else {
reasoningEffort = string(thinking.LevelXHigh)
}
case "disabled":