From de0ce24c2e5660bf74d69cfd888e91d648cae54d Mon Sep 17 00:00:00 2001 From: ZachariahChu <1762459322@qq.com> Date: Sun, 26 Jul 2026 20:29:45 +0800 Subject: [PATCH] perf(cli): cap /model picker custom-endpoint probe at 1.5s The interactive /model picker probes the current custom endpoint live via fetch_api_models(), which defaults to a 5s timeout. A slow or flaky custom endpoint blocks the picker for up to 5s on open. The lmstudio picker probe already uses a 1.5s timeout for exactly this reason; apply the same fast-fail bound to the three custom-provider probe sites, gated on for_picker so the non-picker (5s) path is unchanged. --- hermes_cli/model_switch.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hermes_cli/model_switch.py b/hermes_cli/model_switch.py index ef33260e2d..252986ed30 100644 --- a/hermes_cli/model_switch.py +++ b/hermes_cli/model_switch.py @@ -2702,6 +2702,7 @@ def list_authenticated_providers( live_models = fetch_api_models( api_key, api_url, + timeout=1.5 if for_picker else 5.0, # picker: fail fast so a slow custom endpoint doesn't block /model headers=_extra_headers_from_config(ep_cfg) or None, ) if live_models: @@ -2769,7 +2770,11 @@ def list_authenticated_providers( try: from hermes_cli.models import fetch_api_models - _live_models = fetch_api_models("", str(current_base_url).strip().rstrip("/")) + _live_models = fetch_api_models( + "", + str(current_base_url).strip().rstrip("/"), + timeout=1.5 if for_picker else 5.0, # picker: fail fast on a slow current endpoint + ) if _live_models: _models = _live_models except Exception: @@ -3012,6 +3017,7 @@ def list_authenticated_providers( live_models = fetch_api_models( api_key, api_url, + timeout=1.5 if for_picker else 5.0, # picker: fail fast so a slow custom endpoint doesn't block /model headers=grp.get("extra_headers") or None, ) if live_models: