Skip to content

The agent that grows with you

fix(state): avoid overlapping context manager change

fangliquan59c7a9908420
diff --git a/hermes_state.py b/hermes_state.py
index fe284fab1fd..e0de71e3ec3 100644
--- a/hermes_state.py
+++ b/hermes_state.py
@@ -4429,12 +4429,6 @@ class SessionDB(SessionSearchMixin, SessionSchemaMixin, SessionPortabilityMixin)
conn, self._conn = self._conn, None
self._close_connection_quietly(conn)
- def __enter__(self) -> "SessionDB":
- return self
-
- def __exit__(self, _exc_type, _exc, _tb) -> None:
- self.close()
-
def __del__(self) -> None:
"""Safety net: close the connection if the caller forgot.
diff --git a/tests/test_hermes_state.py b/tests/test_hermes_state.py
index 89abd59d186..6f03a945b6c 100644
--- a/tests/test_hermes_state.py
+++ b/tests/test_hermes_state.py
@@ -104,17 +104,6 @@ def _no_fts_rebuild_throttle(monkeypatch):
class TestConnectionLifecycle:
- def test_context_manager_closes_connection(self, tmp_path):
- from hermes_cli.sqlite_safe_read import has_live_connection
-
- db_path = tmp_path / "context-managed.db"
- with SessionDB(db_path=db_path) as managed:
- managed.create_session("s-context", source="test")
- assert has_live_connection(db_path) is True
-
- assert managed._conn is None
- assert has_live_connection(db_path) is False
-
def test_failed_writable_open_does_not_leak_tracked_connection(
self, tmp_path, monkeypatch
):