fix(copilot): clamp reasoning effort to the nearest supported level, not xhigh->high

The Copilot provider profile unconditionally mapped ``xhigh`` to ``high`` before
checking the model's catalog, so models that DO support ``xhigh`` (e.g. the
gpt-5.x family per the live /models catalog) were silently capped one level
down.

Honor the requested effort when the catalog lists it as supported, and only
downgrade when it does not, choosing the nearest weaker supported level
(xhigh->high, minimal->low, else medium, else the first supported level). This
matches the nearest-down clamp behavior used elsewhere for the ``max`` effort.

Adds tests/plugins/model_providers/test_copilot_profile.py covering forward,
downgrade, and fallback paths (catalog lookup stubbed).
This commit is contained in:
arminanton 2026-06-23 11:06:17 -07:00 committed by Teknium
parent 633fc7ab88
commit cf73b3d411
2 changed files with 121 additions and 3 deletions

View file

@ -35,9 +35,25 @@ class CopilotProfile(ProviderProfile):
supported_efforts = github_model_reasoning_efforts(model)
if supported_efforts and reasoning_config:
effort = reasoning_config.get("effort", "medium")
# Normalize stronger generic levels to the nearest supported.
if effort in {"xhigh", "max", "ultra"}:
effort = "high"
# Honor the requested level when the live Copilot catalog
# lists it as supported: gpt-5.5/gpt-5.4 DO support
# ``xhigh``. Only downgrade levels the catalog does NOT
# list (e.g. ``xhigh``/``max`` on models capped lower, or
# ``minimal`` where unsupported), choosing the nearest
# weaker supported level rather than forwarding verbatim.
#
# (Previously this unconditionally mapped xhigh->high, a
# stale guard that silently capped models which do support
# the higher level.)
if effort not in supported_efforts:
if effort == "xhigh" and "high" in supported_efforts:
effort = "high"
elif effort == "minimal" and "low" in supported_efforts:
effort = "low"
elif "medium" in supported_efforts:
effort = "medium"
else:
effort = supported_efforts[0]
if effort in supported_efforts:
extra_body["reasoning"] = {"effort": effort}
elif supported_efforts: