feat(thinking): add adaptive thinking support for Claude models

Add support for Claude's "adaptive" and "auto" thinking modes using `output_config.effort`. Introduce support for new effort level "max" in adaptive thinking. Update thinking logic, validate model capabilities, and extend converters and handling to ensure compatibility with adaptive modes. Adjust static model data with supported levels and refine handling across translators and executors.
This commit is contained in:
hkfires
2026-03-03 09:05:31 +08:00
parent 09fec34e1c
commit c44793789b
13 changed files with 310 additions and 48 deletions

View File

@@ -231,9 +231,22 @@ func ConvertClaudeRequestToCodex(modelName string, inputRawJSON []byte, _ bool)
}
}
case "adaptive", "auto":
// Claude adaptive/auto means "enable with max capacity"; keep it as highest level
// and let ApplyThinking normalize per target model capability.
reasoningEffort = string(thinking.LevelXHigh)
// 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.
effort := ""
if v := rootResult.Get("output_config.effort"); v.Exists() && v.Type == gjson.String {
effort = strings.ToLower(strings.TrimSpace(v.String()))
}
switch effort {
case "low", "medium", "high":
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.
reasoningEffort = string(thinking.LevelXHigh)
}
case "disabled":
if effort, ok := thinking.ConvertBudgetToLevel(0); ok && effort != "" {
reasoningEffort = effort