The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): re-supply the launch key on the snapshot rejoin's new connection
kshitijk4poorfcbacdea6b81
diff --git a/hermes_cli/cli_snapshot.py b/hermes_cli/cli_snapshot.pyindex a0788b20a68..6ed3dfcbc57 100644--- a/hermes_cli/cli_snapshot.py+++ b/hermes_cli/cli_snapshot.py@@ -121,7 +121,9 @@ def _restore_gateway_snapshot(cli, store, snap_id):store.current = None# The restore's own result or error decides the reply; a failed rejoin must not replace it.try:- store.connection = GatewayConnection.shared()+ drained, store.connection = store.connection, GatewayConnection.shared()+ # The relaunched owner revoked this CLI's launch-only key: every resume re-supplies it.+ store.connection.launch_api_key = drained.launch_api_key_rejoin_cli(cli, store)except Exception as exc:logger.warning("Rejoin after snapshot restore failed: %s", exc, exc_info=True)diff --git a/tests/hermes_cli/test_gateway_snapshot_restore_guards.py b/tests/hermes_cli/test_gateway_snapshot_restore_guards.pyindex 4b6750864c4..c439b78f71d 100644--- a/tests/hermes_cli/test_gateway_snapshot_restore_guards.py+++ b/tests/hermes_cli/test_gateway_snapshot_restore_guards.py@@ -14,6 +14,7 @@ from hermes_cli.gateway_session_store import GatewaySessionStoreclass _Connection:def __init__(self):self.final = False+ self.launch_api_key = Nonedef close(self):self.final = True@@ -59,6 +60,7 @@ def test_restore_reply_follows_the_restore_not_the_rejoin(tmp_path, monkeypatch,(home / "config.yaml").write_text("{}\n", encoding="utf-8")snapshot = create_quick_snapshot(hermes_home=home)old = _Connection()+ old.launch_api_key = "launch-only-key" # --api-key: the rejoin's resumes must re-supply itstore = GatewaySessionStore(old)cli = SimpleNamespace(_session_db=store, _gateway_session_open=True, session_id="kept",agent=object(), conversation_history=[])@@ -93,3 +95,4 @@ def test_restore_reply_follows_the_restore_not_the_rejoin(tmp_path, monkeypatch,assert store.connection is old # a remote chat keeps its connection tooelse:assert "Reconnecting to the gateway failed: permission_denied" in out+ assert store.connection is not old and store.connection.launch_api_key == "launch-only-key"