fix: correct complexity routing to not fall back to default model
Some checks failed
Tests / lint (pull_request) Failing after 17s
Tests / test (pull_request) Has been skipped

`_get_model_for_complexity` was calling `get_model_with_capability`,
which silently falls back to the provider default when no model has the
requested capability tag.  This caused the method to return a generic
model instead of None when neither the fallback chain nor any explicit
capability tag matched, misleading callers into skipping the provider
default logic.

Replace the call with an explicit next() comprehension that returns None
when no model explicitly carries the 'routine' or 'complex' capability.

Refs #1065

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Alexander Whitestone
2026-03-23 15:30:23 -04:00
parent 6c5f55230b
commit 0b284972cb

View File

@@ -545,8 +545,12 @@ class CascadeRouter:
if any(m["name"] == model_name for m in provider.models): if any(m["name"] == model_name for m in provider.models):
return model_name return model_name
# Direct capability lookup as a secondary pass # Direct capability lookup — only return if a model explicitly has the tag
cap_model = provider.get_model_with_capability(chain_key) # (do not use get_model_with_capability here as it falls back to the default)
cap_model = next(
(m["name"] for m in provider.models if chain_key in m.get("capabilities", [])),
None,
)
if cap_model: if cap_model:
return cap_model return cap_model