Skip to content

The agent that grows with you

fix(models): merge StepFun Step Plan live list with curated catalog on the picker path

Brooklyn Nicholson7cb4aa783faa
diff --git a/hermes_cli/model_setup_flows.py b/hermes_cli/model_setup_flows.py
index 3dbc4e8aff5..025f5ece278 100644
--- a/hermes_cli/model_setup_flows.py
+++ b/hermes_cli/model_setup_flows.py
@@ -669,7 +669,7 @@ def _model_flow_stepfun(config, current_model=""):
from hermes_cli.main_provider_setup import _infer_stepfun_region, _prompt_provider_choice, _stepfun_base_url_for_region
from hermes_cli.auth import PROVIDER_REGISTRY
from hermes_cli.config import save_env_value
- from hermes_cli.models import _PROVIDER_MODELS, fetch_api_models
+ from hermes_cli.models import _PROVIDER_MODELS, fetch_api_models, provider_model_ids
provider_id = "stepfun"
pconfig = PROVIDER_REGISTRY[provider_id]
base_url_env = pconfig.base_url_env_var or ""
@@ -699,7 +699,9 @@ def _model_flow_stepfun(config, current_model=""):
if base_url_env:
save_env_value(base_url_env, effective_base)
- model_list = fetch_api_models(existing_key, effective_base)
+ # Same live+curated merge as the picker (``_stepfun_catalog``): Step Plan /models omits
+ # Standard-API-only models, so the wizard must offer the same list /model shows (#41147).
+ model_list = provider_model_ids(provider_id) or fetch_api_models(existing_key, effective_base)
if model_list:
print(f" Found {len(model_list)} model(s) from {pconfig.name} API")
else:
diff --git a/hermes_cli/models.py b/hermes_cli/models.py
index 2690b95ca3a..9d922ba0850 100644
--- a/hermes_cli/models.py
+++ b/hermes_cli/models.py
@@ -884,14 +884,8 @@ def curated_models_for_provider(
# Try live API first (Codex, Nous, etc. all support /models)
live = provider_model_ids(normalized)
if live:
- # For StepFun, the Step Plan API may return a subset of models.
- # Merge live results with the static catalog so models available
- # via the Standard API (e.g. step-3.7-flash) still appear in the
- # picker even when the configured base_url points to Step Plan.
- if normalized == "stepfun":
- static = _PROVIDER_MODELS.get(normalized, [])
- merged = list(dict.fromkeys(live + static))
- return [(m, "") for m in merged]
+ # StepFun's Step Plan /models merge now lives in its provider fetcher
+ # (``_stepfun_catalog``) so every picker surface sees the same list.
return [(m, "") for m in live]
# Fallback to static catalog
@@ -1428,6 +1422,23 @@ def _api_key_provider_live(normalized: str, force_refresh: bool) -> Optional[lis
return None
+def _stepfun_catalog(normalized: str, force_refresh: bool) -> Optional[list[str]]:
+ """Step Plan live list merged with the curated catalog (the ``_anthropic_catalog`` pattern).
+
+ The StepFun inference endpoint is the Step Plan API, whose ``/models`` returns a subset of
+ the full catalog: it omits models served by the Standard API (e.g. ``step-3.7-flash``),
+ so a healthy live response would shadow curated-only models from every picker surface
+ (#41147). Live rows first, then curated-only additions — and when the probe declines
+ (no credentials / failure) ``None`` falls through to the generic profile path, whose
+ ``merge_profile_catalog`` already serves the curated floor as a placeholder.
+ """
+ live = _api_key_provider_live(normalized, force_refresh)
+ if not live:
+ return live
+ curated = list(_PROVIDER_MODELS.get(normalized, []))
+ return _merge_unique(live, curated, key=_model_dedup_key) if curated else live
+
+
def _anthropic_catalog(normalized: str, force_refresh: bool) -> list[str]:
model_cfg = _get_model_config_dict()
cfg_base_url = cfg_api_key = ""
@@ -1538,7 +1549,7 @@ _PROVIDER_CATALOG_FETCHERS: dict[str, Any] = {
"copilot": _copilot_catalog,
"copilot-acp": _copilot_catalog,
"nous": _nous_catalog,
- "stepfun": _api_key_provider_live,
+ "stepfun": _stepfun_catalog,
"gmi": _api_key_provider_live,
"anthropic": _anthropic_catalog,
"ai-gateway": lambda normalized, force_refresh: _fetch_ai_gateway_models() or None,
diff --git a/tests/hermes_cli/test_stepfun_picker_merge.py b/tests/hermes_cli/test_stepfun_picker_merge.py
new file mode 100644
index 00000000000..31fd748dd92
--- /dev/null
+++ b/tests/hermes_cli/test_stepfun_picker_merge.py
@@ -0,0 +1,109 @@
+"""StepFun /model picker merges the Step Plan live catalog with the curated list.
+
+The StepFun provider's inference endpoint is the Step Plan API, whose /models
+returns a subset of the full catalog (it omits ``step-3.7-flash``). Every real
+picker surface resolves through ``provider_model_ids`` -> the stepfun fetcher
+(``_api_key_provider_live``), so the merge must happen there: a working live
+response may no longer shadow curated-only models. (#41147)
+"""
+
+from contextlib import contextmanager
+from unittest.mock import patch
+
+import pytest
+
+from hermes_cli.models import provider_model_ids
+
+STEPFUN_CREDS = {
+ "provider": "stepfun",
+ "api_key": "sk-stepfun-test",
+ "base_url": "https://api.stepfun.ai/step_plan/v1",
+}
+
+STEP_PLAN_LIVE_IDS = ["step-3.5-flash", "step-3.5-flash-2603"]
+
+
+def hermetic_home(tmp_path, monkeypatch):
+ """Isolated HERMES_HOME so the picker cannot read a real disk cache row."""
+ from hermes_constants import reset_hermes_home_override, set_hermes_home_override
+
+ home = tmp_path / "stepfun-home"
+ home.mkdir()
+ token = set_hermes_home_override(str(home))
+ yield home
+ reset_hermes_home_override(token)
+
+
+@contextmanager
+def step_plan_live_listing(ids):
+ """Patch the stepfun credential resolver and /v1/models probe."""
+ with patch(
+ "hermes_cli.auth.resolve_api_key_provider_credentials",
+ return_value=dict(STEPFUN_CREDS),
+ ), patch("hermes_cli.models.fetch_api_models", return_value=list(ids)):
+ yield
+
+
+class TestStepfunPickerMergesLiveWithCurated:
+ def test_live_step_plan_response_still_lists_curated_only_models(self, hermetic_home):
+ """The reported repro: live Step Plan up, step-3.7-flash still missing."""
+ with step_plan_live_listing(STEP_PLAN_LIVE_IDS):
+ ids = provider_model_ids("stepfun")
+ assert "step-3.7-flash" in ids, (
+ "stepfun picker dropped a curated model when the Step Plan live fetch succeeded"
+ )
+ # Live rows keep their position ahead of curated-only additions.
+ assert ids[:2] == STEP_PLAN_LIVE_IDS
+
+ def test_merge_dedupes_and_keeps_the_curated_floor(self, hermetic_home):
+ with step_plan_live_listing(STEP_PLAN_LIVE_IDS):
+ ids = provider_model_ids("stepfun")
+ assert len(ids) == len(set(i.lower() for i in ids)), "duplicate rows in merged picker"
+ from hermes_cli.models_catalog_static import _PROVIDER_MODELS
+
+ for curated_id in _PROVIDER_MODELS["stepfun"]:
+ assert curated_id in ids
+
+ def test_failed_live_fetch_keeps_curated_placeholder(self, hermetic_home):
+ """Outage fallback unchanged: the curated list, flagged as placeholder."""
+ with step_plan_live_listing([]):
+ ids = provider_model_ids("stepfun")
+ from hermes_cli.models_catalog_static import CuratedFallbackModels, _PROVIDER_MODELS
+
+ assert list(ids) == list(_PROVIDER_MODELS["stepfun"])
+ # The placeholder flag rides on the list subclass, so the disk cache can
+ # tell an outage row from the account's real catalog.
+ assert isinstance(ids, CuratedFallbackModels)
+
+ def test_wizard_offer_merges_live_and_curated(self, hermetic_home):
+ """The setup wizard's StepFun flow must offer the same merged list."""
+ from hermes_cli.model_setup_flows import _model_flow_stepfun
+
+ captured = {}
+
+ def fake_pick(model_list, *args, **kwargs):
+ captured["models"] = list(model_list)
+ return None
+
+ with patch(
+ "hermes_cli.model_setup_flows._ensure_flow_api_key", return_value=(None, "sk-stepfun-test", False)
+ ), patch(
+ "hermes_cli.main_provider_setup._prompt_provider_choice", return_value=0
+ ), patch("hermes_cli.config.save_env_value"), patch(
+ "hermes_cli.model_setup_flows._pick_model_or_prompt", side_effect=fake_pick
+ ), patch(
+ "hermes_cli.model_setup_flows._finish_model", return_value=None
+ ):
+ _model_flow_stepfun({})
+ assert "step-3.7-flash" in captured["models"], (
+ "StepFun setup wizard offered the unmerged Step Plan list"
+ )
+ # Contract: the wizard offers the same MERGED list as the picker — every
+ # Step Plan live id plus the curated floor, no duplicates.
+ assert set(STEP_PLAN_LIVE_IDS) <= {m.lower() for m in captured["models"]}
+ from hermes_cli.models_catalog_static import _PROVIDER_MODELS
+
+ for curated_id in _PROVIDER_MODELS["stepfun"]:
+ assert curated_id in captured["models"]
+ assert len(captured["models"]) == len({m.lower() for m in captured["models"]})