Skip to content

The agent that grows with you

fix: export sessions without mutating canonical storage

Tekniumae82c1a2d0cc
diff --git a/hermes_cli/sessions_cmd.py b/hermes_cli/sessions_cmd.py
index 8c2311fe9a3..cb000646b85 100644
--- a/hermes_cli/sessions_cmd.py
+++ b/hermes_cli/sessions_cmd.py
@@ -957,6 +957,7 @@ def cmd_sessions(args, sessions_parser=None):
from hermes_constants import get_hermes_home
path = get_hermes_home() / "state.db"
empty_messages = {
+ "export": "No sessions found.",
"list": "No sessions found.",
"stats": "Total sessions: 0\nTotal messages: 0",
"pinned": "[]" if getattr(args, "json", False) else
diff --git a/tests/hermes_cli/test_sessions_observation.py b/tests/hermes_cli/test_sessions_observation.py
index daf85a69802..7bc20dc8675 100644
--- a/tests/hermes_cli/test_sessions_observation.py
+++ b/tests/hermes_cli/test_sessions_observation.py
@@ -26,10 +26,11 @@ if POPULATED:
db.create_session('observation-fixture', source='cli')
db.append_message('observation-fixture', role='user', content='fixture')
before = path.read_bytes() if path.exists() else None
-for action in ('list', 'stats', 'pinned'):
+for action in ('list', 'stats', 'pinned', 'export'):
output = io.StringIO()
with redirect_stdout(output):
- result = cmd_sessions(SimpleNamespace(sessions_action=action, source=None, limit=20, json=True))
+ result = cmd_sessions(SimpleNamespace(sessions_action=action, source=None, limit=20, json=True,
+ session_id=None, redact=False, format='jsonl', output='-', dry_run=False))
text = output.getvalue()
assert result in (None, 0), text
assert 'Error:' not in text, text
@@ -39,6 +40,8 @@ for action in ('list', 'stats', 'pinned'):
assert ('Total sessions: 1' if POPULATED else 'Total sessions: 0') in text, text
if action == 'pinned':
assert text.strip() == '[]', text
+ if action == 'export':
+ assert ('observation-fixture' if POPULATED else 'No sessions found.') in text, text
after = path.read_bytes() if path.exists() else None
assert after == before, action + ' created or mutated state.db'
'''.replace('POPULATED', repr(populated))