Normalize effort values on the adaptive-thinking path

Bedrock's output_config.effort only accepts low/medium/high (plus xhigh
on models that advertise it via supports_xhigh_reasoning_effort). The
ReasoningEffort range also includes "minimal" and "xhigh", which were
previously embedded verbatim and would trigger an opaque 400 on
adaptive-thinking models. Map "minimal" to "low", and downgrade
"xhigh" to "high" on models that don't support it.
This commit is contained in:
Gabriel Ruel-Fiset 2026-06-09 15:42:43 -04:00
parent 25674b52f4
commit dc705c9d55
No known key found for this signature in database
GPG key ID: AC741D35D648C38E
2 changed files with 16 additions and 1 deletions

View file

@ -168,6 +168,12 @@ def model_supports_adaptive_thinking(model_name: str) -> bool:
return bool(entry and entry.get("supports_adaptive_thinking"))
def model_supports_xhigh_effort(model_name: str) -> bool:
"""Whether the model accepts the ``xhigh`` effort tier."""
entry = _model_cost_entry(model_name)
return bool(entry and entry.get("supports_xhigh_reasoning_effort"))
def is_known_openai_bare_model(model_name: str) -> bool:
import litellm

View file

@ -12,6 +12,7 @@ from strix.config.models import (
DEFAULT_MODEL_RETRY,
model_supports_adaptive_thinking,
model_supports_reasoning,
model_supports_xhigh_effort,
)
@ -129,11 +130,19 @@ def make_model_settings(
# Newer Anthropic models (e.g. Claude Opus 4.8) reject the legacy
# ``thinking.type=enabled`` shape that LiteLLM emits from
# ``reasoning_effort``. Send the adaptive-thinking API instead.
# Bedrock's ``output_config.effort`` only accepts low/medium/high
# (plus xhigh on models that advertise it), so normalize the wider
# ReasoningEffort range onto that set.
effort = reasoning_effort
if effort == "minimal":
effort = "low"
elif effort == "xhigh" and not model_supports_xhigh_effort(model_name):
effort = "high"
model_settings = model_settings.resolve(
ModelSettings(
extra_args={
"thinking": {"type": "adaptive"},
"output_config": {"effort": reasoning_effort},
"output_config": {"effort": effort},
},
),
)