The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): delete-class session mutations carry the generation the owner fences on
Teknium1e388c87e5f0
diff --git a/hermes_cli/gateway_session_store.py b/hermes_cli/gateway_session_store.pyindex 92a6d9461d4..c5f6f6908bf 100644--- a/hermes_cli/gateway_session_store.py+++ b/hermes_cli/gateway_session_store.py@@ -40,6 +40,8 @@ _GATEWAY_OWNED = frozenset({"update_session_model", "patch_session_model_config", "maybe_auto_archive","maybe_auto_prune_and_vacuum", "set_meta", "update_token_counts", "close",})+# Mutations the owner refuses without the execution generation they were read at (hermes_state_runtime).+_GENERATION_FENCED = frozenset({"delete", "rewind", "reset", "branch", "model", "compress"})_COUNTED_REPAIRS = frozenset({"prune_empty_ghost_sessions", "finalize_orphaned_compression_sessions"})# Launch options main's ``cli.main`` takes that are creation policy on the gateway session._LAUNCH_POLICY = ("model", "provider", "toolsets", "reasoning", "api_key", "base_url", "max_turns",@@ -161,12 +163,13 @@ class GatewaySessionStore:self._adopt(self.attach(child))return child- def _revision(self, session_id):- return self.call("session.resume", session_id=session_id)["revision"]-def _mutate(self, session_id, operation, payload):+ snapshot = self.call("session.resume", session_id=session_id)+ fence = {}+ if operation in _GENERATION_FENCED:+ fence["expected_generation"] = snapshot["execution_generation"]return self.call("session.mutate", session_id=session_id, request_id=uuid.uuid4().hex,- expected_revision=self._revision(session_id), operation=operation, payload=payload)+ expected_revision=snapshot["revision"], operation=operation, payload=payload, **fence)def set_session_title(self, session_id, title):try:diff --git a/tests/hermes_cli/test_gateway_session_store.py b/tests/hermes_cli/test_gateway_session_store.pyindex 6ebd3c4be71..2af03c3e22c 100644--- a/tests/hermes_cli/test_gateway_session_store.py+++ b/tests/hermes_cli/test_gateway_session_store.py@@ -107,7 +107,9 @@ def test_title_rename_delete_and_detach_are_gateway_verbs(store):assert client.calls[-1] == ("session.detach", {"session_id": "local-old", "subscription_id": "sub-local-old","end_reason": "cli_close"})db.delete_session("local-old")- assert [p for m, p in client.calls if m == "session.mutate"][-1]["operation"] == "delete"+ delete = [p for m, p in client.calls if m == "session.mutate"][-1]+ # The owner refuses a delete without the generation it was read at (invalid_params).+ assert delete["operation"] == "delete" and delete["expected_generation"] == 0def test_gateway_owned_writes_are_noops_and_unknown_writes_refuse(store):