The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(state): delete_session_if_empty returns False for a guarded row
kshitijk4poorf34a71d3c51a
diff --git a/hermes_state_sessions.py b/hermes_state_sessions.pyindex fe1e26508bb..7e137ea3ecf 100644--- a/hermes_state_sessions.py+++ b/hermes_state_sessions.py@@ -1654,12 +1654,10 @@ class SessionSessionsMixin:share one transaction so a concurrent flush can't be lost. A row under an active turn leaseor compression lock is never a candidate: the emptiness predicate reads committed state, so arow whose first turn is already leased but not yet flushed would be deleted mid-turn- (#123583). Raises :class:`SessionActiveWriteGuardError` like the guarded deletes."""+ (#123583). A guarded row is simply not deleted (returns ``False``), like any non-empty row."""def _do(conn):if self._guarded_ids(conn, [session_id]):- raise SessionActiveWriteGuardError(- f"session '{session_id}' has an active turn lease or compression lock"- )+ return Falsecursor = conn.execute("""DELETE FROM sessionsdiff --git a/tests/hermes_state/test_delete_session_write_guards.py b/tests/hermes_state/test_delete_session_write_guards.pyindex 07f8ab200e2..174b0780218 100644--- a/tests/hermes_state/test_delete_session_write_guards.py+++ b/tests/hermes_state/test_delete_session_write_guards.py@@ -101,8 +101,7 @@ def test_delete_session_if_empty_refuses_when_write_guard_active(tmp_path):turn_holder = f"pid={os.getpid()}:turn=1"assert db.try_acquire_session_turn_lease("empty-live", turn_holder, ttl_seconds=300.0) is True- with pytest.raises(SessionActiveWriteGuardError):- db.delete_session_if_empty("empty-live")+ assert db.delete_session_if_empty("empty-live") is Falseassert db.get_session("empty-live") is not Nonedb.release_session_turn_lease("empty-live", turn_holder)