Skip to content

The agent that grows with you

fix(gateway): /model listing reads catalogs cache-only, never joins live probes

kshitijk4poorcb24121a8ef2
diff --git a/gateway/slash_commands_model.py b/gateway/slash_commands_model.py
index 15fbb5a444d..7ae52e7274c 100644
--- a/gateway/slash_commands_model.py
+++ b/gateway/slash_commands_model.py
@@ -394,11 +394,7 @@ class GatewayModelCommandsMixin:
"""Send the interactive /model picker; False when nothing was sent (text fallback). *source*
is session-key-normalized so the picker's thread metadata lands where the next turn reads."""
from hermes_cli.model_switch_providers import list_picker_providers
- try: # off-loop: listing can hit a synchronous HTTP fetch on a stale cache
- # Offload blocking provider-listing (can fall through to a synchronous urllib HTTP fetch on a
- # stale cache) off the event loop so the gateway doesn't freeze. See #41289.
- # Offload blocking provider-listing off the event loop so the gateway doesn't freeze on a
- # stale-cache HTTP fetch. See #41289.
+ try: # off-loop: listing still reads config/disk cache synchronously (#41289)
providers = await asyncio.to_thread(
list_picker_providers, max_models=50, include_moa=True, **listing_kwargs
)
@@ -426,6 +422,9 @@ class GatewayModelCommandsMixin:
current_provider=ctx.current_provider, current_base_url=ctx.current_base_url,
current_model=ctx.current_model, user_providers=ctx.user_provs,
custom_providers=ctx.custom_provs, excluded_providers=ctx.excluded_provs,
+ # Chat `/model` is a read path: catalogs come from the disk cache and stale ones warm
+ # in the background, so one degraded provider can't stall the reply (#74003).
+ non_blocking_catalogs=True,
)
adapter = self._delivery_adapter_for(ctx.source)
if adapter is not None and getattr(type(adapter), "send_model_picker", None) is not None:
@@ -447,7 +446,7 @@ class GatewayModelCommandsMixin:
return None # Picker sent — adapter handles the response
lines = [t("gateway.model.current_label", model=ctx.current_model or "unknown", provider=get_label(ctx.current_provider)), ""]
- try: # off-loop: listing can hit a stale-cache HTTP fetch
+ try: # off-loop: listing still reads config/disk cache synchronously (#41289)
providers = await asyncio.to_thread(list_authenticated_providers, max_models=5, **listing_kwargs)
lines.extend(_model_provider_listing_lines(providers))
except Exception:
diff --git a/hermes_cli/model_switch_providers.py b/hermes_cli/model_switch_providers.py
index c2aa01b50d0..8164ec91a68 100644
--- a/hermes_cli/model_switch_providers.py
+++ b/hermes_cli/model_switch_providers.py
@@ -1301,18 +1301,21 @@ def _prepend_moa_picker_provider(providers: List[dict], current_provider: str =
def list_picker_providers(
current_provider: str = "", current_base_url: str = "", user_providers: dict = None,
custom_providers: list | None = None, max_models: int | None = None, current_model: str = "",
- include_moa: bool = False, excluded_providers: list | None = None) -> List[dict]:
+ include_moa: bool = False, excluded_providers: list | None = None,
+ non_blocking_catalogs: bool = False) -> List[dict]:
"""Interactive-picker variant of :func:`list_authenticated_providers`.
OpenRouter's list is replaced with :func:`hermes_cli.models.fetch_openrouter_models` (curated
snapshot filtered against the live catalog) and rows left with no models are dropped — except
- custom endpoints, where the user may supply their own model set through config."""
+ custom endpoints, where the user may supply their own model set through config.
+ ``non_blocking_catalogs`` is forwarded unchanged (cache-only catalogs, background warm)."""
from hermes_cli.model_switch import list_authenticated_providers
from hermes_cli.models import fetch_openrouter_models
providers = list_authenticated_providers(
current_provider=current_provider, current_base_url=current_base_url,
user_providers=user_providers, custom_providers=custom_providers, max_models=max_models,
- current_model=current_model, for_picker=True, excluded_providers=excluded_providers)
+ current_model=current_model, for_picker=True, excluded_providers=excluded_providers,
+ non_blocking_catalogs=non_blocking_catalogs)
if include_moa:
providers = _prepend_moa_picker_provider(providers, current_provider=current_provider)