Skip to content

The agent that grows with you

fix: retain legacy session writers during reader migration

Teknium82dfb85d6789
diff --git a/hermes_cli/sessions_cmd.py b/hermes_cli/sessions_cmd.py
index f992b655956..8c2311fe9a3 100644
--- a/hermes_cli/sessions_cmd.py
+++ b/hermes_cli/sessions_cmd.py
@@ -966,7 +966,7 @@ def cmd_sessions(args, sessions_parser=None):
if read_only and not path.exists():
print(empty_messages[action])
return
- db = SessionDB(db_path=path, read_only=read_only)
+ db = SessionDB(db_path=path, read_only=True) if read_only else SessionDB()
except Exception as e:
print(f"Error: Could not open session database: {e}")
return 1
diff --git a/tests/hermes_cli/test_sessions_pin.py b/tests/hermes_cli/test_sessions_pin.py
index aa4c3b0b797..81d5aea6350 100644
--- a/tests/hermes_cli/test_sessions_pin.py
+++ b/tests/hermes_cli/test_sessions_pin.py
@@ -9,6 +9,14 @@ not a client-local list.
import json
import sys
+import pytest
+
+
[email protected](autouse=True)
+def existing_store(tmp_path, monkeypatch):
+ monkeypatch.setattr("hermes_constants.get_hermes_home", lambda: tmp_path)
+ (tmp_path / "state.db").touch()
+
class _FakeDB:
def __init__(self, rows=None, known=("20260315_092437_c9a6ff",)):
@@ -43,7 +51,11 @@ def _run(monkeypatch, capsys, argv_tail, db):
import hermes_cli.main as main_mod
import hermes_state
- monkeypatch.setattr(hermes_state, "SessionDB", lambda: db)
+ def open_db(**kwargs):
+ assert kwargs.get("read_only", False) == (argv_tail[0] == "pinned")
+ return db
+
+ monkeypatch.setattr(hermes_state, "SessionDB", open_db)
monkeypatch.setattr(sys, "argv", ["hermes", "sessions", *argv_tail])
try:
main_mod.main()