The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(setup): reconcile_record() only reconciles the launch profile's record
teknium1b9629c298ef5
diff --git a/hermes_cli/free_tier_bootstrap.py b/hermes_cli/free_tier_bootstrap.pyindex 0274ca9f299..5ccdba1ca8a 100644--- a/hermes_cli/free_tier_bootstrap.py+++ b/hermes_cli/free_tier_bootstrap.py@@ -90,10 +90,15 @@ def reconcile_record() -> Optional[SetupRecord]:and its retries mint. A record that already says ``True`` is never re-probed, so the answeronly moves false -> true here. Every write path that assigns the main model (the Models page,a picker key save) calls this for the immediate broadcast; ``setup.status`` calls it for- writes this process never saw (``hermes setup`` / ``hermes model`` from a shell, a hand edit)."""+ writes this process never saw (``hermes setup`` / ``hermes model`` from a shell, a hand edit).+ The record is the LAUNCH profile's: a call scoped to another profile's home (a dashboard+ write with ``?profile=B``) leaves it alone, or B's providers would open the launch gate."""global _recordrecord = _record- if record is None or record.provider_configured or _inventory_stamp == _config_stamp():+ if record is None or record.provider_configured:+ return record+ from hermes_constants import get_process_hermes_home, hermes_home_key+ if hermes_home_key() != hermes_home_key(get_process_hermes_home()) or _inventory_stamp == _config_stamp():return recordif not _inventory_other_providers():return _recorddiff --git a/tests/hermes_cli/test_resolve_provider_custom_endpoint.py b/tests/hermes_cli/test_resolve_provider_custom_endpoint.pyindex 2c9c03b3599..7b228ad6187 100644--- a/tests/hermes_cli/test_resolve_provider_custom_endpoint.py+++ b/tests/hermes_cli/test_resolve_provider_custom_endpoint.py@@ -106,6 +106,18 @@ def test_a_provider_configured_after_boot_flips_the_stale_setup_record(isolated_assert boot.provider_configured is Falseassert fb.wait_for_record(timeout=0) is boot and broadcasts == [], "blank machine: nothing to reconcile"+ # The record is the launch profile's: a write scoped to another profile (the dashboard's+ # ``?profile=b``) must not let THAT profile's provider open the launch gate.+ from hermes_constants import reset_hermes_home_override, set_hermes_home_override+ profile_b = isolated_home / "profiles" / "b"+ profile_b.mkdir(parents=True)+ (profile_b / "config.yaml").write_text("model:\n default: qwen3\n provider: custom\n base_url: http://127.0.0.1:8000/v1\n api_key: dummy\n", encoding="utf-8")+ token = set_hermes_home_override(str(profile_b))+ try:+ assert fb.reconcile_record() is boot and broadcasts == [], "another profile's provider is not ours"+ finally:+ reset_hermes_home_override(token)+(isolated_home / "config.yaml").write_text("model:\n default: qwen3\n provider: custom\n base_url: http://127.0.0.1:8000/v1\n api_key: dummy\n",encoding="utf-8",diff --git a/tests/tui_gateway/test_tui_gateway_server.py b/tests/tui_gateway/test_tui_gateway_server.pyindex fea556633a4..42d2de3c2b0 100644--- a/tests/tui_gateway/test_tui_gateway_server.py+++ b/tests/tui_gateway/test_tui_gateway_server.py@@ -16968,6 +16968,40 @@ def test_model_save_key_uses_credential_lifecycle_and_picker_context(monkeypatch)+def test_model_save_key_reconciles_the_launch_profiles_stale_setup_record(monkeypatch):+ """The gated picker's own chat waits on ``setup.status``, which answers from the boot record:+ a key saved for the launch profile must flip a ``False`` record (+ ``setup.ready``) at once;+ a key saved for another profile (``profile`` param) must leave the launch record alone."""+ from hermes_cli import free_tier_bootstrap as fb++ monkeypatch.setattr("hermes_cli.auth.PROVIDER_REGISTRY", {"test-provider": types.SimpleNamespace(+ name="Test Provider", auth_type="api_key", api_key_env_vars=("TEST_PROVIDER_API_KEY",))})+ monkeypatch.setattr("hermes_cli.config.is_managed", lambda: False)+ monkeypatch.setattr("hermes_cli.credential_lifecycle.save_provider_env_credential", Mock())+ monkeypatch.setattr("hermes_cli.inventory.build_models_payload", Mock(return_value={"providers": []}))+ monkeypatch.setenv("TEST_PROVIDER_API_KEY", "previous-value") # save_key exports the new key+ monkeypatch.setattr(fb, "_inventory_other_providers", lambda: True)+ monkeypatch.setattr(fb, "_resolve_inference", lambda: "test-provider")+ broadcasts = []+ monkeypatch.setattr(fb, "_broadcast", broadcasts.append)+ fb.reset_for_tests()+ stale = fb.SetupRecord(provider_configured=False, inference_provider="", free_tier=False,+ has_identity=False, other_providers=False)+ with fb._lock:+ fb._record, fb._started = stale, True+ fb._done.set()+ try:+ params = {"slug": "test-provider", "api_key": "k-" + "1"}+ assert "result" in server._methods["model.save_key"](104, {**params, "profile": "other"})+ assert fb.current_record() is stale and broadcasts == [], "another profile's key is not ours"+ assert "result" in server._methods["model.save_key"](105, params)+ record = fb.current_record()+ assert record.provider_configured is True and record.inference_provider == "test-provider"+ assert broadcasts == [record]+ finally:+ fb.reset_for_tests()++# ---------------------------------------------------------------------------# prompt.submit — auto-title# ---------------------------------------------------------------------------