fix: map adaptive thinking to xhigh reasoning_effort instead of high

When thinking.type is "adaptive" (Claude's maximum thinking mode) and
output_config.effort is absent, resolve_reasoning_effort() incorrectly
mapped it to "high" instead of "xhigh" in OpenAI format conversions.
This commit is contained in:
Jason
2026-04-10 19:22:39 +08:00
parent a83bd90fa9
commit af679cda25
2 changed files with 7 additions and 7 deletions

View File

@@ -35,7 +35,7 @@ pub fn supports_reasoning_effort(model: &str) -> bool {
/// `low`/`medium`/`high` map 1:1; `max` maps to `xhigh`
/// (supported by mainstream GPT models). Unknown values are ignored.
/// 2. Fallback: `thinking.type` + `budget_tokens`:
/// - `adaptive` → `high` (mirrors optimizer semantics where adaptive ≈ max effort)
/// - `adaptive` → `xhigh` (adaptive = maximum reasoning effort)
/// - `enabled` with budget → `low` (<4 000) / `medium` (4 00015 999) / `high` (≥16 000)
/// - `enabled` without budget → `high` (conservative default)
/// - `disabled` / absent → `None`
@@ -57,7 +57,7 @@ pub fn resolve_reasoning_effort(body: &Value) -> Option<&'static str> {
// --- Priority 2: thinking.type + budget_tokens fallback ---
let thinking = body.get("thinking")?;
match thinking.get("type").and_then(|t| t.as_str()) {
Some("adaptive") => Some("high"),
Some("adaptive") => Some("xhigh"),
Some("enabled") => {
let budget = thinking.get("budget_tokens").and_then(|b| b.as_u64());
match budget {
@@ -1019,9 +1019,9 @@ mod tests {
}
#[test]
fn test_thinking_adaptive_maps_high() {
fn test_thinking_adaptive_maps_xhigh() {
let body = json!({"thinking": {"type": "adaptive"}});
assert_eq!(resolve_reasoning_effort(&body), Some("high"));
assert_eq!(resolve_reasoning_effort(&body), Some("xhigh"));
}
#[test]
@@ -1100,7 +1100,7 @@ mod tests {
});
let result = anthropic_to_openai(input, None).unwrap();
assert_eq!(result["reasoning_effort"], "high");
assert_eq!(result["reasoning_effort"], "xhigh");
}
#[test]

View File

@@ -1047,7 +1047,7 @@ mod tests {
}
#[test]
fn test_responses_thinking_adaptive_sets_reasoning_high() {
fn test_responses_thinking_adaptive_sets_reasoning_xhigh() {
let input = json!({
"model": "gpt-5.4",
"max_tokens": 1024,
@@ -1056,7 +1056,7 @@ mod tests {
});
let result = anthropic_to_responses(input, None, false).unwrap();
assert_eq!(result["reasoning"]["effort"], "high");
assert_eq!(result["reasoning"]["effort"], "xhigh");
}
#[test]