Skip to content

The agent that grows with you

fix(left-core): a provider installed during resolution resolves in that same call

Teknium5a87b601853a
diff --git a/hermes_cli/left_core_migration.py b/hermes_cli/left_core_migration.py
index 6d34f0b88c8..ef5442d5f27 100644
--- a/hermes_cli/left_core_migration.py
+++ b/hermes_cli/left_core_migration.py
@@ -1022,6 +1022,8 @@ def _install_one(home: Path, feature: LeftCoreFeature, *, install: Callable[[str
except Exception as exc: # network, uv, kill list — report, do not raise
result = {"ok": False, "error": str(exc)}
if result.get("ok"):
+ from providers import refresh_bound_home
+ refresh_bound_home() # a provider plugin resolves in this same call, not after the stamp TTL
try:
_record_migration(home, feature)
except Exception as exc: # the next run sees the plugin dir and records it then
diff --git a/providers/__init__.py b/providers/__init__.py
index 8d91bd6a411..4988f33726c 100644
--- a/providers/__init__.py
+++ b/providers/__init__.py
@@ -411,6 +411,12 @@ def _home_layer(*, force_stamp_check: bool = False) -> _HomeLayer:
return layer
+def refresh_bound_home() -> None:
+ """Re-scan the bound home's plugin dirs now and forget its remembered misses: a plugin was just
+ installed there, and the periodic check (or a name's miss back-off) would hide it for up to a TTL."""
+ _home_layer(force_stamp_check=True).misses.clear()
+
+
def _bound_home_layer() -> tuple[_HomeLayer, Path | None, str]:
try:
from hermes_constants import get_hermes_home, hermes_home_key
diff --git a/tests/hermes_cli/test_left_core_provider_runtime.py b/tests/hermes_cli/test_left_core_provider_runtime.py
index bbc4c3bec0a..bf758214d83 100644
--- a/tests/hermes_cli/test_left_core_provider_runtime.py
+++ b/tests/hermes_cli/test_left_core_provider_runtime.py
@@ -247,3 +247,40 @@ def test_a_piped_cli_front_end_prints_the_outcome_and_what_another_process_kept(
assert err.count("kept by the gateway's start") == 1
assert err.count("GitHub Copilot moved out of core") == 1
assert "moved out of core" not in _agent_start_in_another_process()
+
+
+_INSTALLED_PROVIDER = """
+from providers import register_provider
+from providers.base import ProviderProfile
+
+register_provider(ProviderProfile(name="copilot", display_name="Stand-in", auth_type="api_key",
+ env_vars=("COPILOT_GITHUB_TOKEN",), base_url="https://copilot.stand-in.test/v1"))
+"""
+
+
+def test_a_provider_installed_during_resolution_resolves_in_that_same_call(tmp_path, monkeypatch):
+ """A fast (cached) install lands inside the plugin-dir stamp TTL: the resolution that triggered it must
+ see the new profile, not answer "installed but not loaded: run hermes plugins enable"."""
+ import sys
+
+ import providers
+ home = _copilot_home(tmp_path, monkeypatch)
+ monkeypatch.setenv("COPILOT_GITHUB_TOKEN", "stand-in-token")
+ monkeypatch.setattr(providers, "_HOME_LAYERS", {})
+
+ def install(identifier, *, force, enable, catalog_name=None, assume_deps_consent=None, **kw):
+ plugin = home / "plugins" / "github-copilot"
+ plugin.mkdir(parents=True)
+ (plugin / "plugin.yaml").write_text("name: github-copilot\nkind: model-provider\n", encoding="utf-8")
+ (plugin / "__init__.py").write_text(_INSTALLED_PROVIDER, encoding="utf-8")
+ return {"ok": True}
+ import hermes_cli.plugins_cmd as pc
+ monkeypatch.setattr(pc, "dashboard_install_plugin", install)
+ monkeypatch.delenv("HERMES_DISABLE_LAZY_INSTALLS", raising=False)
+ from hermes_cli.runtime_provider import resolve_runtime_provider
+ try:
+ runtime = resolve_runtime_provider()
+ assert (runtime["provider"], runtime["base_url"]) == ("copilot", "https://copilot.stand-in.test/v1")
+ finally:
+ for name in [m for m in sys.modules if m.startswith("_hermes_user_provider")]:
+ del sys.modules[name]