The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(left-core): count cron.model_provider and delegation backend routes as provider use
Teknium1843ff74c9f0
diff --git a/cron/scheduler_preflight.py b/cron/scheduler_preflight.pyindex 17a3cd7ec8d..ce4cda23792 100644--- a/cron/scheduler_preflight.py+++ b/cron/scheduler_preflight.py@@ -83,6 +83,12 @@ def _cron_preflight_enabled(cfg: dict) -> bool:return not isinstance(cron_cfg, dict) or cron_cfg.get("preflight", True) is not False+def cron_default_provider(cfg: dict) -> str:+ """``cron.model_provider``: the provider every cron job without its own pin resolves through."""+ cron = cfg.get("cron") if isinstance(cfg, dict) else None+ return str(cron.get("model_provider") or "").strip() if isinstance(cron, dict) else ""++def _preflight_check_provider_key(job: dict, cfg: dict) -> Optional[str]:"""READ-ONLY probe: would provider resolution fail for lack of a key? Mirrors run_job'srequested-provider computation. Skipped when the job has a fallback chain — auth-fallback may@@ -94,9 +100,7 @@ def _preflight_check_provider_key(job: dict, cfg: dict) -> Optional[str]:except Exception:return None # fail-open: never block on a preflight-internal error- _cron_cfg = cfg.get("cron") if isinstance(cfg.get("cron"), dict) else {}- requested = (- job.get("provider") or str((_cron_cfg or {}).get("model_provider") or "").strip() or None)+ requested = job.get("provider") or cron_default_provider(cfg) or Nonemodel = job.get("model") or cron_env_setting("HERMES_MODEL") or ""from hermes_cli.auth import AuthError, is_rate_limited_auth_errordiff --git a/hermes_cli/left_core_migration.py b/hermes_cli/left_core_migration.pyindex 02f5a0594f4..007f3e619c3 100644--- a/hermes_cli/left_core_migration.py+++ b/hermes_cli/left_core_migration.py@@ -233,9 +233,11 @@ def camofox_in_use(home: Path, *, process_env: bool = False) -> bool:def _provider_choices(home: Path) -> set[str]:"""Every provider *home* routes inference through, read with core's own loaders: config.yaml with themanaged overlay (``read_yaml_layers``): ``model``, the fallback chain (``get_fallback_chain``: legacy- ``fallback_model`` merged), each ``auxiliary.<task>``, ``delegation`` and its fallback chain, every MoA- preset's reference models and aggregator (``normalize_moa_config``); the ``auth.json``- ``active_provider`` the resolver's auto rung follows; and the provider each cron job pinned."""+ ``fallback_model`` merged), each ``auxiliary.<task>``, ``delegation`` and its fallback chain, every+ delegation backend route (:func:`_delegation_backend_routes`) and its chain, every MoA preset's reference+ models and aggregator (``normalize_moa_config``); the ``auth.json`` ``active_provider`` the resolver's auto+ rung follows; the cron-wide ``cron.model_provider`` and the provider each cron job pinned."""+ from cron.scheduler_preflight import cron_default_providerfrom gateway import config_loaderfrom hermes_cli.fallback_config import get_fallback_chainfrom hermes_cli.moa_config import normalize_moa_config@@ -248,11 +250,15 @@ def _provider_choices(home: Path) -> set[str]:def block(value) -> dict:return value if isinstance(value, dict) else {}+ def with_chain(slot: dict) -> list[dict]:+ return [slot, *get_fallback_chain({"fallback_providers": slot.get("fallback_providers")})]delegation = block(cfg.get("delegation"))slots = [block(cfg.get("model")), *get_fallback_chain(cfg), *map(block, block(cfg.get("auxiliary")).values()),- delegation, *get_fallback_chain({"fallback_providers": delegation.get("fallback_providers")})]+ *with_chain(delegation), {"provider": cron_default_provider(cfg)}]for preset in normalize_moa_config(cfg.get("moa"))["presets"].values():slots += [*map(block, preset.get("reference_models") or []), block(preset.get("aggregator"))]+ for route in _delegation_backend_routes(delegation):+ slots += with_chain(route)import jsontry:jobs = json.loads((home / "cron" / "jobs.json").read_text(encoding="utf-8-sig")).get("jobs")@@ -264,6 +270,16 @@ def _provider_choices(home: Path) -> set[str]:return chosen - {""}+def _delegation_backend_routes(delegation: dict) -> list[dict]:+ """The routes of every ``delegation.backends.<name>`` block: each entry of its ``options`` list (the+ ``model_map`` backend's titled provider/model routes, the shape ``web_routers/delegation.py`` writes).+ While a backend is active, these are the only routes delegated children take. The backends are+ plugins, so no core loader reads them; any backend using the ``options`` shape counts."""+ backends = delegation.get("backends")+ blocks = [b for b in backends.values() if isinstance(b, dict)] if isinstance(backends, dict) else []+ return [o for b in blocks if isinstance(b.get("options"), list) for o in b["options"] if isinstance(o, dict)]++def providers_selected(home: Path, names: tuple[str, ...], *, process_env: bool = False) -> set[str]:"""The provider *names* (ids or aliases) *home* routes inference through (:func:`_provider_choices`),or names in its ``HERMES_INFERENCE_PROVIDER`` (dotenv layers; the process env too for the launch homediff --git a/tests/hermes_cli/test_left_core_provider_rows.py b/tests/hermes_cli/test_left_core_provider_rows.pyindex a032e595c58..24852cf7925 100644--- a/tests/hermes_cli/test_left_core_provider_rows.py+++ b/tests/hermes_cli/test_left_core_provider_rows.py@@ -62,6 +62,12 @@ def _home(tmp_path: Path, *, env: str = "", config: str = "", auth: dict | None("", "HERMES_INFERENCE_PROVIDER=copilot\n", None, None),("", "", {"active_provider": "copilot"}, None),("", "", None, [{"id": "j1", "provider": "copilot", "model": "gpt-5.4"}]),+ ("cron:\n model: gpt-5.4\n model_provider: copilot\n", "", None, None),+ ("delegation:\n backend: model_map\n backends:\n model_map:\n options:\n - name: fast\n"+ " provider: copilot\n model: gpt-5.4\n", "", None, None),+ ("delegation:\n backends:\n model_map:\n options:\n - name: deep\n provider: nous\n"+ " fallback_providers:\n - provider: github-copilot\n model: gpt-5.4\n",+ "", None, None),])def test_copilot_in_use_is_any_provider_slot_naming_it(tmp_path, config, env, auth, jobs):assert lcm.copilot_in_use(_home(tmp_path, config=config, env=env, auth=auth, jobs=jobs)) is Truediff --git a/tests/hermes_cli/test_left_core_provider_runtime.py b/tests/hermes_cli/test_left_core_provider_runtime.pyindex 76370778787..8c4c42aa494 100644--- a/tests/hermes_cli/test_left_core_provider_runtime.py+++ b/tests/hermes_cli/test_left_core_provider_runtime.py@@ -88,3 +88,15 @@ def test_a_failed_attempt_is_not_rechecked_on_every_resolution(tmp_path, monkeyplcm.recover_for_provider("copilot")assert len(calls) == first++[email protected]("config", [+ "model:\n provider: nous\ncron:\n model_provider: copilot\n",+ "model:\n provider: nous\ndelegation:\n backends:\n model_map:\n options:\n"+ " - name: fast\n provider: copilot\n model: gpt-5.4\n",+])+def test_a_route_configured_outside_the_main_model_installs_when_resolved(tmp_path, monkeypatch, installs, config):+ """A cron run or a routed delegate resolves the provider its config slot names: that is use."""+ _copilot_home(tmp_path, monkeypatch, config)+ _resolve(requested="copilot")+ assert installs == [("github-copilot", True)]