Skip to content

The agent that grows with you

test(models): azure-foundry picker invariants; docs: /model lists Foundry deployments

teknium1cfd4921be6ba
diff --git a/tests/hermes_cli/test_models.py b/tests/hermes_cli/test_models.py
index a5f9bc93cd2..4f890945ac1 100644
--- a/tests/hermes_cli/test_models.py
+++ b/tests/hermes_cli/test_models.py
@@ -1572,3 +1572,38 @@ class TestOpenRouterCatalogDiskCache:
path.write_text("{not json")
assert fetch_openrouter_models() == [("a/one", "free")]
assert len(calls) == 2
+
+
+class TestAzureFoundryPickerCatalog:
+ """``/model azure-foundry`` lists the resource's live ``/models`` ids (#27989).
+
+ Deployments are per-resource and the plugin profile ships ``base_url=""``, so the generic
+ profile fetch never fires; the picker used to fall through to the static ``[]``.
+ """
+
+ def test_provider_model_ids_probes_the_configured_resource(self, monkeypatch):
+ seen = {}
+
+ def fake_runtime(*, requested_provider, model_cfg, **_):
+ return {"base_url": "https://r.openai.azure.com/openai/v1/", "api_key": "k"}
+
+ def fake_probe(base_url, credential, **_):
+ seen.update(base_url=base_url, credential=credential)
+ return True, ["gpt-5.4", "kimi-k2.6"]
+
+ monkeypatch.setattr("hermes_cli.runtime_provider._resolve_azure_foundry_runtime", fake_runtime)
+ monkeypatch.setattr("hermes_cli.azure_detect._probe_openai_models", fake_probe)
+ assert _models_mod.provider_model_ids("azure-foundry", force_refresh=True) == ["gpt-5.4", "kimi-k2.6"]
+ assert seen == {"base_url": "https://r.openai.azure.com/openai/v1", "credential": "k"}
+
+ def test_probe_miss_or_resolver_error_keeps_the_empty_static_catalog(self, monkeypatch):
+ monkeypatch.setattr("hermes_cli.azure_detect._probe_openai_models", lambda *a, **k: (False, []))
+ monkeypatch.setattr("hermes_cli.runtime_provider._resolve_azure_foundry_runtime",
+ lambda **_: {"base_url": "https://r.services.ai.azure.com/anthropic", "api_key": "k"})
+ assert _models_mod.provider_model_ids("azure-foundry", force_refresh=True) == []
+
+ def raising(**_):
+ raise RuntimeError("Azure Foundry requires a base URL")
+
+ monkeypatch.setattr("hermes_cli.runtime_provider._resolve_azure_foundry_runtime", raising)
+ assert _models_mod.provider_model_ids("azure-foundry", force_refresh=True) == []
diff --git a/tests/hermes_cli/test_user_providers_model_switch.py b/tests/hermes_cli/test_user_providers_model_switch.py
index 963ab9c98f6..b8a00d02e8d 100644
--- a/tests/hermes_cli/test_user_providers_model_switch.py
+++ b/tests/hermes_cli/test_user_providers_model_switch.py
@@ -614,3 +614,23 @@ def test_current_custom_model_not_leaked_into_other_provider_rows(monkeypatch):
for row in providers:
if row["slug"] != "openrouter" and not row.get("is_current"):
assert custom not in row.get("models", []), f"leaked into {row['slug']}"
+
+
+def test_overlay_provider_row_merges_configured_models(monkeypatch):
+ """A ``providers.<overlay>.models`` block extends a Hermes-overlay row (azure-foundry) the way
+ it already extends built-in rows; the picker used to show only the live/current id (#27989)."""
+ from hermes_cli.providers import HERMES_OVERLAYS
+
+ monkeypatch.setattr("agent.models_dev.fetch_models_dev", lambda: {})
+ monkeypatch.setattr("agent.models_dev.PROVIDER_TO_MODELS_DEV", {})
+ monkeypatch.setattr("hermes_cli.providers.HERMES_OVERLAYS", {"azure-foundry": HERMES_OVERLAYS["azure-foundry"]})
+ monkeypatch.setattr("hermes_cli.models.cached_provider_model_ids", lambda *_a, **_k: ["gpt-5.6-sol", "shared"])
+ monkeypatch.setenv("AZURE_FOUNDRY_API_KEY", "test-key")
+
+ rows = list_authenticated_providers(
+ current_provider="azure-foundry", max_models=50,
+ user_providers={"azure-foundry": {"models": ["gpt-5.5", "shared", "gpt-4.1-mini"]}})
+ row = next(r for r in rows if r["slug"] == "azure-foundry")
+ assert row["source"] == "hermes"
+ assert row["models"] == ["gpt-5.5", "shared", "gpt-4.1-mini", "gpt-5.6-sol"]
+ assert row["total_models"] == 4
diff --git a/website/docs/guides/azure-foundry.md b/website/docs/guides/azure-foundry.md
index b1098e5ba30..9ca8121f294 100644
--- a/website/docs/guides/azure-foundry.md
+++ b/website/docs/guides/azure-foundry.md
@@ -275,12 +275,24 @@ Azure does **not** expose a pure-API-key endpoint to list your *deployed* model
What Hermes can do:
-- Azure OpenAI v1 endpoints (`<resource>.openai.azure.com/openai/v1`) expose `GET /models` with the resource's **available** model catalog. Hermes uses this list to prefill the model picker.
-- Microsoft Foundry `/anthropic` routes: detected via URL path, model name entered manually.
+- Azure OpenAI v1 endpoints (`<resource>.openai.azure.com/openai/v1`) expose `GET /models` with the resource's **available** model catalog. Hermes uses this list to prefill the setup wizard's model picker **and** the in-session `/model azure-foundry` picker (CLI, TUI, Desktop, gateway), so you can switch deployments without re-running `hermes setup`.
+- Microsoft Foundry `/anthropic` routes: detected via URL path, model name entered manually (no `/models` there — the `/model` picker shows only the current selection and any `providers.azure-foundry.models` you declare).
- Private / firewalled endpoints: manual entry with a friendly "couldn't probe" message.
You can always type a deployment name directly — Hermes does not validate against the returned list.
+To pin the picker to the deployments you actually use (the catalog can be long), or to list them for an endpoint without `/models`, declare them in `config.yaml`; they are listed first, ahead of the live catalog:
+
+```yaml
+providers:
+ azure-foundry:
+ models:
+ - gpt-5.4
+ - kimi-k2.6
+```
+
+The runtime picker resolves the endpoint from `model.base_url` while Azure Foundry is the active provider; set `AZURE_FOUNDRY_BASE_URL` as well if you want the row to stay populated after switching to another provider.
+
## Environment variables
| Variable | Purpose |