The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(sessions): refresh epoch survives compression rotation; --session targets the tip
Teknium0216b1a320fa
diff --git a/hermes_cli/sessions_cmd.py b/hermes_cli/sessions_cmd.pyindex 041deb11837..ae92efd1e37 100644--- a/hermes_cli/sessions_cmd.py+++ b/hermes_cli/sessions_cmd.py@@ -1320,6 +1320,8 @@ def _cmd_refresh_prompts(db, args):if not session_id:print(f"No session matches {target!r}.")return 1+ # A compressed conversation continues on its tip; a request keyed on the ended root never fires.+ session_id = db.get_compression_tip(session_id) or session_idrow = db.get_session(session_id) or {}count = 1 if row.get("system_prompt") else 0else:diff --git a/hermes_state_compression.py b/hermes_state_compression.pyindex 82f5cc121c6..c97da84f110 100644--- a/hermes_state_compression.py+++ b/hermes_state_compression.py@@ -84,7 +84,9 @@ _CHAIN_CAP = 1000# model_config keys that belong to the whole conversation, not one compression segment: a rotation# carries them onto the child (per-segment keys such as usage anchors stay behind).-_CONVERSATION_MODEL_CONFIG_KEYS = ("onboarding_run",)+# ``prompt_refresh_epoch`` too: without it a rotated child looks older than any past+# ``hermes sessions refresh-prompts`` request and rebuilds its prompt once more after eviction.+_CONVERSATION_MODEL_CONFIG_KEYS = ("onboarding_run", "prompt_refresh_epoch")def _walk_compression_chain(session_id: str, step) -> list[str]:diff --git a/tests/agent/test_session_prompt_refresh.py b/tests/agent/test_session_prompt_refresh.pyindex 0bf3c2bdde8..181747062c2 100644--- a/tests/agent/test_session_prompt_refresh.py+++ b/tests/agent/test_session_prompt_refresh.py@@ -392,3 +392,33 @@ def test_a_bot_chat_rebuild_satisfies_a_pending_refresh(profile, monkeypatch):history, third = _turn(srv, home, "chat-bot2", "third", history)assert third == rebuiltassert builds == []+++def _rotate(srv, home, session_id):+ """Fill a session, then compact it with rotation (``compression.in_place: false``)."""+ warm = _agent(srv, home, session_id)+ history = []+ try:+ for i in range(14):+ history, _ = _turn(srv, home, session_id, f"turn {i} " + f"lorem ipsum dolor {i} " * 200,+ history, agent=warm)+ warm.compression_in_place = False+ compressed, _ = warm._compress_context(history, None, force=True)+ assert warm.session_id != session_id+ return warm.session_id, compressed+ finally:+ warm.close()+++def test_rotated_compression_keeps_the_refresh_epoch_and_session_flag_targets_the_tip(profile, monkeypatch):+ srv, home, project = profile+ _refresh_prompts(monkeypatch, home) # a past profile-wide request+ child, history = _rotate(srv, home, "chat-rot")+ builds = _count_builds(monkeypatch)+ history, _ = _turn(srv, home, child, "after eviction", history)+ assert builds == [] # the child satisfies the past request; no extra cache break++ _update_profile(home, project)+ _refresh_prompts(monkeypatch, home, "--session", "chat-rot") # the conversation's original id+ _, refreshed = _turn(srv, home, child, "next", history)+ _assert_updated(refreshed)