perf(state): counters from the rows in hand, bounded identity read, one row-identity helper
Efficiency gate: replace_messages had swapped the free insert-return counters for a full active-set rescan (JSON parse per row) on every branch, slowing the untouched compress/ACP path; the counts are now kept-prefix (from the fetched rows) + inserted. The identity SELECT is bounded to len(messages)+1 rows — the prefix plus the row that anchors the archive UPDATE. _row_identity is the one place the compared columns are spelled; _kept_live_prefix became _stamp_kept_live_prefix (it mutates _row_id); rewind's _comparison_content delegates to the shared _loaded_view_content.
This commit is contained in:
@@ -34,12 +34,9 @@ def _user_indices(messages: List[Dict[str, Any]]) -> List[int]:
|
||||
def _comparison_content(message: Dict[str, Any]) -> Any:
|
||||
"""Project content the way the durable row stores it (flush projection, then the read-side sanitize) so a
|
||||
warm row and its durable twin compare equal."""
|
||||
from agent.memory_manager import sanitize_context
|
||||
from agent.session_persistence import _durable_content
|
||||
content = _durable_content(message.get("content"))
|
||||
if message.get("role") in {"user", "assistant"} and isinstance(content, str):
|
||||
return sanitize_context(content).strip()
|
||||
return content
|
||||
from hermes_state_messages import SessionMessagesMixin
|
||||
return SessionMessagesMixin._loaded_view_content(message.get("role"), _durable_content(message.get("content")))
|
||||
|
||||
|
||||
class SessionRewindMixin:
|
||||
|
||||
Reference in New Issue
Block a user