fix: correct complexity routing to not fall back to default model
`_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:
@@ -545,8 +545,12 @@ class CascadeRouter:
|
||||
if any(m["name"] == model_name for m in provider.models):
|
||||
return model_name
|
||||
|
||||
# Direct capability lookup as a secondary pass
|
||||
cap_model = provider.get_model_with_capability(chain_key)
|
||||
# Direct capability lookup — only return if a model explicitly has the tag
|
||||
# (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:
|
||||
return cap_model
|
||||
|
||||
|
||||
Reference in New Issue
Block a user