Improved tracer workflow tool
Updated 2.5 pro model name Add metadata to results Fix for https://github.com/BeehiveInnovations/zen-mcp-server/issues/98
This commit is contained in:
@@ -207,9 +207,34 @@ class OpenRouterProvider(OpenAICompatibleProvider):
|
||||
|
||||
if self._registry:
|
||||
for model_name in self._registry.list_models():
|
||||
# Check restrictions if enabled
|
||||
if restriction_service and not restriction_service.is_allowed(self.get_provider_type(), model_name):
|
||||
continue
|
||||
# =====================================================================================
|
||||
# CRITICAL ALIAS-AWARE RESTRICTION CHECKING (Fixed Issue #98)
|
||||
# =====================================================================================
|
||||
# Previously, restrictions only checked full model names (e.g., "google/gemini-2.5-pro")
|
||||
# but users specify aliases in OPENROUTER_ALLOWED_MODELS (e.g., "pro").
|
||||
# This caused "no models available" error even with valid restrictions.
|
||||
#
|
||||
# Fix: Check both model name AND all aliases against restrictions
|
||||
# TEST COVERAGE: tests/test_provider_routing_bugs.py::TestOpenRouterAliasRestrictions
|
||||
# =====================================================================================
|
||||
if restriction_service:
|
||||
# Get model config to check aliases as well
|
||||
model_config = self._registry.resolve(model_name)
|
||||
allowed = False
|
||||
|
||||
# Check if model name itself is allowed
|
||||
if restriction_service.is_allowed(self.get_provider_type(), model_name):
|
||||
allowed = True
|
||||
|
||||
# CRITICAL: Also check aliases - this fixes the alias restriction bug
|
||||
if not allowed and model_config and model_config.aliases:
|
||||
for alias in model_config.aliases:
|
||||
if restriction_service.is_allowed(self.get_provider_type(), alias):
|
||||
allowed = True
|
||||
break
|
||||
|
||||
if not allowed:
|
||||
continue
|
||||
|
||||
models.append(model_name)
|
||||
|
||||
|
||||
@@ -179,7 +179,21 @@ class ModelProviderRegistry:
|
||||
continue
|
||||
|
||||
for model_name in available:
|
||||
if restriction_service and not restriction_service.is_allowed(provider_type, model_name):
|
||||
# =====================================================================================
|
||||
# CRITICAL: Prevent double restriction filtering (Fixed Issue #98)
|
||||
# =====================================================================================
|
||||
# Previously, both the provider AND registry applied restrictions, causing
|
||||
# double-filtering that resulted in "no models available" errors.
|
||||
#
|
||||
# Logic: If respect_restrictions=True, provider already filtered models,
|
||||
# so registry should NOT filter them again.
|
||||
# TEST COVERAGE: tests/test_provider_routing_bugs.py::TestOpenRouterAliasRestrictions
|
||||
# =====================================================================================
|
||||
if (
|
||||
restriction_service
|
||||
and not respect_restrictions # Only filter if provider didn't already filter
|
||||
and not restriction_service.is_allowed(provider_type, model_name)
|
||||
):
|
||||
logging.debug("Model %s filtered by restrictions", model_name)
|
||||
continue
|
||||
models[model_name] = provider_type
|
||||
|
||||
Reference in New Issue
Block a user