Skip to content

The agent that grows with you

fix(gateway): scope the plugin update-check chore per served profile

ethernet5c733f2066bb
diff --git a/gateway/run.py b/gateway/run.py
index e23443d7b67..ec8398f9548 100644
--- a/gateway/run.py
+++ b/gateway/run.py
@@ -4821,7 +4821,9 @@ def _start_gateway_housekeeping(
lambda _launch=_launch_sessions_dir(getattr(runner, "config", None)):
_housekeeping_state_db_maintenance(_launch))),
# Due-gated inside: the first tick after startup runs an overdue check, not tick 60.
- (1, "Plugin update check", _housekeeping_plugin_update_check),
+ # Per served profile: plugins dir, last-run marker and plugins.auto_apply are all the
+ # profile's own (get_hermes_home()/load_config_readonly() bind to the scope).
+ (1, "Plugin update check", profile_scoped_chore(runner, _housekeeping_plugin_update_check)),
(1, "Deferred FTS retry tick", _housekeeping_deferred_fts_retry),
(1, "gateway housekeeping memory trim", _housekeeping_memory_trim),
(1, "MCP config reconcile", _mcp_config_reconciler(runner)),
diff --git a/tests/gateway/test_housekeeping_profile_scope.py b/tests/gateway/test_housekeeping_profile_scope.py
index 603218f7962..8644dc0371c 100644
--- a/tests/gateway/test_housekeeping_profile_scope.py
+++ b/tests/gateway/test_housekeeping_profile_scope.py
@@ -227,3 +227,34 @@ def test_single_profile_sync_ticks_run_once_against_the_process_home(two_homes,
assert {k: [h for h, _ in v] for k, v in seen.items()} == {
"sync": [a.name], "org": [a.name], "curator": [a.name]}
+
+
+def test_multiplexed_plugin_update_check_visits_every_served_profiles_plugins(two_homes, monkeypatch):
+ """The plugin update check runs once per served profile, against THAT profile's plugins dir
+ and marker, under that profile's ``plugins:`` config. Unscoped it checked the launch home's
+ plugins only, so B's plugins were never checked and B's ``plugins.auto_apply`` was ignored."""
+ from agent.secret_scope import set_multiplex_active
+ from hermes_cli import plugins_cadence
+
+ a, b = two_homes
+ (a / "config.yaml").write_text("plugins:\n auto_update_check_hours: 1\n", encoding="utf-8")
+ (b / "config.yaml").write_text(
+ "plugins:\n auto_update_check_hours: 1\n auto_apply: true\n", encoding="utf-8")
+ checked: list = []
+
+ def _run_checks(plugins_dir, *a_, **k_):
+ checked.append((plugins_dir, plugins_cadence.auto_apply_enabled()))
+ return []
+
+ import hermes_cli.plugins_updates as updates
+ monkeypatch.setattr(updates, "run_checks", _run_checks)
+
+ set_multiplex_active(True)
+ try:
+ _run_60_ticks(SimpleNamespace(config=SimpleNamespace(multiplex_profiles=True)))
+ finally:
+ set_multiplex_active(False)
+
+ assert checked == [(a / "plugins", False), (b / "plugins", True)]
+ assert (a / "plugin-update-checks" / "last-run").exists()
+ assert (b / "plugin-update-checks" / "last-run").exists()