fix(agent): honor explicit model_overrides.supports_reasoning in the reasoning gate - #92768
chelsealong wants to merge 1 commit into
Conversation
…reasoning gate _supports_reasoning_extra_body() decided whether to emit reasoning parameters purely by route (hostname/provider), so an operator running a self-hosted or unrecognized OpenAI-compatible endpoint had no way to tell it their model does (or does not) support reasoning, even though model_overrides.<provider>.<model>.supports_reasoning is a documented, first-class override field already consulted by get_model_capabilities() elsewhere in the codebase. Consult the explicit override first, before any hostname/provider heuristic, so operator intent always wins. Falls through to the existing route-based logic unchanged when no explicit override is set. Fixes NousResearch#92759
Overall: clean precedence fix — an explicit
The |
What
AIAgent._supports_reasoning_extra_body()(run_agent.py) decides whether to emitreasoning parameters purely by route — hostname/provider checks (Nous Portal, Vercel
AI Gateway, GitHub Models/Copilot, LM Studio probe,
ollama.comprobe, OpenRoutermodel-prefix list). Everything else falls through to
False.That leaves operators on a self-hosted or unrecognized OpenAI-compatible endpoint
(e.g. a local Ollama server behind
provider: custom) with no way to say "this modelsupports reasoning" even though
model_overrides.<provider>.<model>.supports_reasoningis already a documented, first-class override field (
agent/models_dev.py:860-884)that
get_model_capabilities()already consults elsewhere in the codebase. There wereno references to
model_overridesanywhere inrun_agent.py.Fix
Consult the explicit override first, via the existing
_explicit_model_override()resolver in
agent/models_dev.py(no new key space, no new machinery), before anyhostname/provider heuristic runs. Operator intent wins when set; everything falls
through to the unchanged existing route-based logic when it isn't. Only explicit
per-model overrides participate — the
_defaultfill-gap entries are intentionallynot consulted here, matching the "operator intent wins" precedence the issue asks for.
This deliberately scopes to just the
model_overrideshalf of the issue's proposal.The issue's other ask — widening the Ollama
/api/showprobe beyondollama.comtoany Ollama-compatible host — is already covered by other open PRs against this same
function (e.g. #86197, #83566) and is left untouched here to avoid overlapping edits
on the same lines.
Testing
Added two tests to
TestSupportsReasoningExtraBodyintests/run_agent/test_run_agent.py:test_explicit_override_enables_reasoning_on_unrouted_host— aprovider: customagent pointed at a local Ollama server (a host none of the existing route checks
recognize) with
supports_reasoning: trueinmodel_overridesnow reportsreasoning-capable.
test_explicit_override_disables_reasoning_on_otherwise_capable_route— an explicitsupports_reasoning: falseoverrides a route that would otherwise sayTrue(adeepseek/model on OpenRouter).Confirmed both fail without the fix (
git checkout HEAD~1 -- run_agent.py):And pass with it:
Full existing suite, green:
Fixes #92759
AI assistance disclosure
This change was authored with the assistance of an AI coding agent (Claude).