The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(telemetry): provider allowlist comes from shipped providers only (B1)
teknium1802e6797a0a4
diff --git a/hermes_cli/observability/shared_metrics_catalog.py b/hermes_cli/observability/shared_metrics_catalog.pyindex 52627a37114..e3b4fbd833f 100644--- a/hermes_cli/observability/shared_metrics_catalog.py+++ b/hermes_cli/observability/shared_metrics_catalog.py@@ -79,12 +79,22 @@ def display_languages() -> frozenset[str]:@functools.cachedef provider_names() -> frozenset[str]:- """Provider ids Hermes itself ships (auth registry, overlays, model catalog, aliases)."""- from hermes_cli.auth import PROVIDER_REGISTRY- from hermes_cli.models import _KNOWN_PROVIDER_NAMES+ """Provider ids Hermes itself ships: built-in auth rows, overlays, alias tables and the+ in-tree ``plugins/model-providers`` profiles. Never the live registries (``PROVIDER_REGISTRY``,+ picker labels): ``$HERMES_HOME`` and pip provider plugins add their user-chosen names there."""+ import providers+ from hermes_cli.auth import _PROVIDER_ALIASES, BUILTIN_PROVIDER_IDS+ from hermes_cli.models_catalog_static import _PROVIDER_ALIASES as _CATALOG_ALIASESfrom hermes_cli.providers import ALIASES, HERMES_OVERLAYS- return frozenset(PROVIDER_REGISTRY) | frozenset(HERMES_OVERLAYS) | frozenset(_KNOWN_PROVIDER_NAMES) | frozenset(ALIASES)+ providers.list_providers() # runs discovery; bundled profiles land in the process-wide layer+ bundled = {+ alias for name, profile in providers._REGISTRY.items() if providers._SOURCES.get(name) == "bundled"+ for alias in (name, *profile.aliases)+ }+ return BUILTIN_PROVIDER_IDS.union(+ HERMES_OVERLAYS, ALIASES, _PROVIDER_ALIASES, _CATALOG_ALIASES, bundled, ("openrouter", CUSTOM)+ )@functools.cachediff --git a/tests/hermes_cli/test_shared_metrics_model_attribution.py b/tests/hermes_cli/test_shared_metrics_model_attribution.pyindex b66184eb47f..caa915ea4e6 100644--- a/tests/hermes_cli/test_shared_metrics_model_attribution.py+++ b/tests/hermes_cli/test_shared_metrics_model_attribution.py@@ -111,6 +111,50 @@ def test_shipped_provider_and_public_model_are_reported_as_is(direct_runtime, tmassert dims["model"] == PUBLIC, (name, dims)+def test_user_provider_plugin_name_and_model_never_leave(direct_runtime, tmp_path, monkeypatch):+ """A ``$HERMES_HOME/plugins/model-providers`` profile joins PROVIDER_REGISTRY under a name (and+ aliases) the user chose: every metric, the provider-setup marker and the snapshot read+ ``custom``/``custom``. An in-tree provider plugin (``deepinfra``) keeps its public name."""+ from hermes_cli import auth, auth_plugin_providers, models_catalog_static as mcs+ from hermes_cli.observability import shared_metrics_catalog as catalog, shared_metrics_setup as setup+ from providers import get_provider_profile++ for mod, attr in ((auth, "PROVIDER_REGISTRY"), (auth_plugin_providers, "PLUGIN_MIRRORED_PROVIDERS"),+ (mcs, "CANONICAL_PROVIDERS"), (mcs, "_canonical_slugs"), (mcs, "_PROVIDER_LABELS")):+ monkeypatch.setattr(mod, attr, type(getattr(mod, attr))(getattr(mod, attr))) # no registry leak+ home = tmp_path / "hermes-home"+ plugin = home / "plugins" / "model-providers" / "acmecorp-internal"+ plugin.mkdir(parents=True)+ (plugin / "plugin.yaml").write_text("name: acmecorp-internal\nkind: model-provider\n")+ (plugin / "__init__.py").write_text(+ "from providers import register_provider\nfrom providers.base import ProviderProfile\n"+ "register_provider(ProviderProfile(name='acmecorp-internal', aliases=('acme-llm',),\n"+ " env_vars=('ACMECORP_LLM_API_KEY',), base_url='https://llm.acmecorp.internal/v1'))\n")+ assert get_provider_profile("acmecorp-internal") is not None+ assert "acmecorp-internal" in auth.PROVIDER_REGISTRY+ catalog.provider_names.cache_clear()++ snapshot = _emit_every_model_metric("acmecorp-internal", SECRET)+ flow = setup.begin_provider_setup("cli_model", "acme-llm")+ marker_dir = home / "telemetry" / "shared_metrics" / "provider_setup_markers"+ markers = [p.read_text() for p in marker_dir.iterdir()]+ setup.finish_provider_setup(flow, "completed")+ _flush()+ rows = _all_rows(home)++ assert markers and not any("acme" in m for m in markers)+ assert "acme" not in json.dumps(rows) + json.dumps(snapshot)+ assert snapshot["main_provider"] == "custom"+ assert _MODEL_METRICS | {"hermes.provider_setup.count"} <= {name for name, _ in rows}+ for name, dims in rows:+ for key in (*_PROVIDER_FIELDS, "to_provider"):+ if dims.get(key) not in (None, "openrouter"):+ assert dims[key] == "custom", (name, dims)+ if "model" in dims:+ assert dims["model"] == "custom", (name, dims)+ assert catalog.provider_metric_name("deepinfra") == "deepinfra"++@pytest.mark.parametrize(("configured", "expected"), [(("custom", "acme-private-llama", "http://localhost:8080/v1"), ("custom", "custom")),(("openrouter", PUBLIC, ""), ("openrouter", PUBLIC)),diff --git a/website/docs/developer-guide/relay-shared-metrics.md b/website/docs/developer-guide/relay-shared-metrics.mdindex 0732d89ffb3..4c6604bfd19 100644--- a/website/docs/developer-guide/relay-shared-metrics.md+++ b/website/docs/developer-guide/relay-shared-metrics.md@@ -348,10 +348,13 @@ local database, so each fires once per install however many processes reach it.#### Per-model quality, friction and context pressure-Provider and model follow the model-route rules: a provider Hermes ships and its-model id; custom endpoints, the local-server aliases of `custom` (`ollama`, `local`,-`vllm`, `llamacpp`, `llama.cpp`) and loopback servers read `custom`, and a model-whose provider is unknown reads `custom`.+Provider and model follow the model-route rules: a provider Hermes ships (built in,+an in-tree `plugins/model-providers/` profile or a public models.dev id) and its+model id; custom endpoints, provider plugins installed under+`$HERMES_HOME/plugins/model-providers/` or from pip (names and aliases included),+the local-server aliases of `custom` (`ollama`, `local`, `vllm`, `llamacpp`,+`llama.cpp`) and loopback servers read `custom`, and a model whose provider is+unknown reads `custom`.| Metric | Dimensions | Question it answers ||---|---|---|