The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
chore(sessions): drop the backfill cursor once done; rewind uses the uid helpers
kshitijk4poord55e320ad2aa
diff --git a/hermes_state_rewind.py b/hermes_state_rewind.pyindex c0619857fa2..a35be4f86b9 100644--- a/hermes_state_rewind.py+++ b/hermes_state_rewind.py@@ -59,6 +59,7 @@ class SessionRewindMixin:_DB_PERSISTED_MARKER, history_before_user_originated_turn, retryable_user_text,split_user_originated_turn, user_originated_turn_view)from agent.message_content import flatten_message_text+ from agent.message_metadata import MESSAGE_UID, message_uid_or_nonefrom agent.session_persistence import _is_ephemeral_scaffoldingexpected_active_ids = self.get_active_message_ids(session_id)@@ -113,8 +114,8 @@ class SessionRewindMixin:raise RuntimeError("rewind did not retain its compaction handoff")# The installed scaffold IS the replacement row: carry its identity, not just its row id.durable_prefix[-1].update({"_row_id": replacement_id, _DB_PERSISTED_MARKER: True})- if isinstance(replacement_uid := result.get("replacement_message_uid"), str) and replacement_uid:- durable_prefix[-1]["message_uid"] = replacement_uid+ if replacement_uid := result.get("replacement_message_uid"):+ durable_prefix[-1][MESSAGE_UID] = replacement_uidprefix[-1] = durable_prefix[-1]if adopt_row_ids and prefix is not durable_prefix and len(prefix) == len(durable_prefix) and all(warm.get("role") == durable_message.get("role")@@ -126,8 +127,8 @@ class SessionRewindMixin:for warm, durable_message in zip(prefix, durable_prefix):if isinstance(row_id := durable_message.get("_row_id"), int):warm["_row_id"] = row_id- if isinstance(uid := durable_message.get("message_uid"), str) and uid:- warm["message_uid"] = uid+ if uid := message_uid_or_none(durable_message):+ warm[MESSAGE_UID] = uidreturn RewindOutcome(prefix=prefix, live_view=live_view,live_text=live_text if live_text is not None else flatten_message_text(live_view.get("content")),diff --git a/hermes_state_schema.py b/hermes_state_schema.pyindex 8f1884390ce..6a78b4a6554 100644--- a/hermes_state_schema.py+++ b/hermes_state_schema.py@@ -1134,6 +1134,7 @@ class SessionSchemaMixin:self.set_meta(_MESSAGE_UID_BACKFILL_CURSOR, str(done_through), cursor=cursor)returnself.set_meta(_MESSAGE_UID_BACKFILL_DONE, "1", cursor=cursor)+ cursor.execute("DELETE FROM state_meta WHERE key = ?", (_MESSAGE_UID_BACKFILL_CURSOR,))def _migrate_v22_session_model_usage(self, cursor: sqlite3.Cursor) -> None:"""v22: ``task`` joins the session_model_usage PRIMARY KEY ('' = main loop; aux calls