The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(config): the v52 browser.backend: off notice reaches the first agent's startup warnings when boot runs the migration
Teknium182fedef9a2f
diff --git a/hermes_cli/config_migrations_browser.py b/hermes_cli/config_migrations_browser.pyindex d38f58abdf7..353dc479e62 100644--- a/hermes_cli/config_migrations_browser.py+++ b/hermes_cli/config_migrations_browser.py@@ -95,7 +95,8 @@ def migrate_to_52(results: dict[str, Any], quiet: bool) -> None:config = read_raw_config()browser = config.get("browser") if isinstance(config.get("browser"), dict) else {}- added, messages = [], []+ # notices: what the user must read even when nothing prints this migration (boot runs it quietly).+ added, messages, notices = [], [], []if "backend" in browser:backend = browser.pop("backend")# YAML 1.1 reads an unquoted `off` as False; core treated that as off too.@@ -105,6 +106,7 @@ def migrate_to_52(results: dict[str, Any], quiet: bool) -> None:"browser now; to turn browsing off, disable the `browser` toolset in `hermes tools`")added.append(note)messages.append(f" ✓ {note[0].upper()}{note[1:]}.")+ notices.append(f"{note[0].upper()}{note[1:]}.")else:added.append("removed browser.backend")if "extension_control" in browser:@@ -129,6 +131,7 @@ def migrate_to_52(results: dict[str, Any], quiet: bool) -> None:config["browser"] = browser_persist_migration(config)results["config_added"].extend(added)+ results.setdefault("notices", []).extend(notices)if not quiet:for message in messages:print(message)diff --git a/hermes_cli/left_core_migration.py b/hermes_cli/left_core_migration.pyindex cc5101b9feb..9525fc7d749 100644--- a/hermes_cli/left_core_migration.py+++ b/hermes_cli/left_core_migration.py@@ -412,6 +412,14 @@ _attempted: set[str] = set()_undelivered: dict[str, list[str]] = {}+def defer_startup_notice(message: str) -> None:+ """Hand *message* to the active home's first agent (its startup-warning sink, through+ :func:`recover_at_startup`), once. For boot-path work that runs before any agent exists."""+ from hermes_constants import get_hermes_home, hermes_home_key+ logger.warning(message)+ _undelivered.setdefault(hermes_home_key(Path(get_hermes_home())), []).append(message)++def plugin_present(plugin: str, home: Path) -> bool:"""Installed in *home* (enabled or not: a user who disabled it chose to). Read-only."""return (home / "plugins" / plugin).is_dir()@@ -720,7 +728,8 @@ def _gateway_serves(home: Path) -> bool:def recover_at_startup(*, say: Optional[Callable[[str], None]] = None) -> list[str]:"""Agent/gateway start hook for the active home: one attempt per process per home. With *say*(an agent's startup-warning sink) outcomes are delivered now, together with any a gateway-start- attempt queued for this home; without it they are logged and queued for the home's first agent.+ attempt or boot maintenance (:func:`defer_startup_notice`) queued for this home; without it they are+ logged and queued for the home's first agent.Returns installed plugin names."""from agent.safe_worker_policy import worker_config_snapshotif worker_config_snapshot() is not None:diff --git a/hermes_cli/post_update.py b/hermes_cli/post_update.pyindex 4bdfcc80064..4bdb20d5465 100644--- a/hermes_cli/post_update.py+++ b/hermes_cli/post_update.py@@ -87,7 +87,7 @@ def step_migrate_config() -> dict:backups = _backup_existing((get_config_path(), get_env_path()))try:- migrate_config(interactive=False, quiet=True)+ results = migrate_config(interactive=False, quiet=True)except Exception:_restore_backups(backups)raise@@ -99,6 +99,10 @@ def step_migrate_config() -> dict:f"(still {post_ver}); restored: "+ (", ".join(str(p) for p in restored) if restored else "none"))+ # `hermes update` prints what a quiet migration changed; boot has no terminal to print it to.+ from hermes_cli.left_core_migration import defer_startup_notice+ for notice in results.get("notices") or ():+ defer_startup_notice(notice)return {"ok": True, "migrated": f"{current_ver}->{latest_ver}"}diff --git a/tests/hermes_cli/test_config_migration_52_browser.py b/tests/hermes_cli/test_config_migration_52_browser.pyindex f24b1fc3bb9..a49445cbd9f 100644--- a/tests/hermes_cli/test_config_migration_52_browser.py+++ b/tests/hermes_cli/test_config_migration_52_browser.py@@ -64,6 +64,36 @@ def test_quiet_migration_hands_the_notice_to_the_caller(tmp_path, monkeypatch, cfor note in results["config_added"])+def _boot_agents(home, monkeypatch, starts: int) -> list[str]:+ """Boot maintenance for *home* (its config step), then *starts* agents in that process; the startup+ warnings they show."""+ import hermes_cli.left_core_migration as lcm+ from hermes_cli import post_update++ monkeypatch.setenv("HERMES_HOME", str(home))+ monkeypatch.setattr(lcm, "_attempted", set())+ post_update.step_migrate_config()+ said = []+ for _ in range(starts):+ lcm.recover_at_startup(say=said.append)+ return said+++def test_boot_migration_shows_the_off_notice_at_the_first_agent_start_once(tmp_path, monkeypatch):+ """Boot migrates 51 -> 52 quietly, before any agent exists: the ``off`` notice reaches the first+ agent's startup warnings once, and neither a second agent nor the next boot repeats it."""+ import hermes_cli.left_core_migration as lcm++ monkeypatch.setattr(lcm, "_undelivered", {})+ monkeypatch.delenv("CAMOFOX_URL", raising=False)+ home = _home(tmp_path / "a", {"_config_version": 51, "browser": {"backend": "off"}})+ said = _boot_agents(home, monkeypatch, starts=2)+ assert _raw(home)["_config_version"] == 52+ assert len(said) == 1+ assert "browser_exec is the browser now" in said[0] and "`browser` toolset in `hermes tools`" in said[0]+ assert _boot_agents(home, monkeypatch, starts=1) == []++@pytest.mark.parametrize("value", ["", "browser-use", "Browser-Use", None])def test_other_backend_values_are_dropped_silently(tmp_path, monkeypatch, capsys, value):monkeypatch.setenv("HERMES_HOME", str(tmp_path / "launch"))