The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(tui): pin TUI /save json to the session profile's export cap
kshitijk4poora9a5c70ee9e2
diff --git a/tests/hermes_cli/test_save_transcript_history.py b/tests/hermes_cli/test_save_transcript_history.pyindex 27488dd8392..2ad9b689e88 100644--- a/tests/hermes_cli/test_save_transcript_history.py+++ b/tests/hermes_cli/test_save_transcript_history.py@@ -60,10 +60,12 @@ def _gateway_save(db, fmt, out):return delivered["text"] if reply == "Export complete." else reply-def _tui_save(db, fmt, out, *, host=False):+def _tui_save(db, fmt, out, *, host=False, profile=False):"""TUI/Desktop ``session.save`` (JSON only); ``host`` forwards it as a control frame to a turn-isolated compute- host, whose own session runs the handler in-process."""+ host, whose own session runs the handler in-process; ``profile`` launches the process from another (uncapped)+ home, so the session's profile config must be the one read."""import json+ import osimport threadingfrom unittest import mock@@ -84,7 +86,8 @@ def _tui_save(db, fmt, out, *, host=False):ComputeHost(stdout=wire, heartbeat_secs=0)._handle_control({"sid": sid, **frame})return json.loads(wire.getvalue())- with mock.patch.dict(server._sessions, {"tui-save": parent}), \+ launch = {"HERMES_HOME": str(out.parent / "launch")} if profile else {}+ with mock.patch.dict(server._sessions, {"tui-save": parent}), mock.patch.dict(os.environ, launch), \mock.patch.object(server, "_session_uses_compute_host", lambda s: host and s is parent), \mock.patch.object(server, "_send_compute_host_control", control):resp = server._methods["session.save"]("1", {"session_id": "tui-save"})@@ -105,8 +108,9 @@ def test_save_transcript_holds_display_history(tmp_path, monkeypatch, save):assert [f"answer {i}" in text for i in range(1, 7)] == [True] * 6[email protected]("save", [_cli_save, _gateway_save, _tui_save, lambda *a: _tui_save(*a, host=True)],- ids=["cli", "gateway", "tui", "tui-compute-host"])[email protected]("save", [_cli_save, _gateway_save, _tui_save, lambda *a: _tui_save(*a, host=True),+ lambda *a: _tui_save(*a, profile=True)],+ ids=["cli", "gateway", "tui", "tui-compute-host", "tui-profile"])def test_save_json_restores_compacted_history_as_archived(tmp_path, monkeypatch, save):"""/save json is the snapshot the dashboard import restores: the turns compaction archived come backin the display history, and stay out of the live context."""@@ -132,8 +136,9 @@ def test_save_json_restores_compacted_history_as_archived(tmp_path, monkeypatch,assert [m["id"] for m in snapshot["messages"]] == kept # every kept row, not the deduped display readassert sum(snapshot["timings"]["role_counts"].values()) == len(kept) # timings name no undone rowassert {i[k] for i in snapshot["timings"]["intervals"] for k in ("from_message_id", "to_message_id")} <= set(kept)- # Like `hermes sessions export`, the in-memory backup is capped per session (sessions.max_export_messages).- monkeypatch.setattr("hermes_state.resolved_max_export_messages", lambda: 5)+ # Like `hermes sessions export`, the in-memory backup is capped per session (the session profile's+ # sessions.max_export_messages).+ (tmp_path / "config.yaml").write_text("sessions:\n max_export_messages: 5\n", encoding="utf-8")assert "max_export_messages" in save(db, "json", tmp_path / "capped.json")finally:db.close()