The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(compression): the repair's row counts are persistence-only message fields
John Paul Solivabbacab42013a
diff --git a/agent/message_metadata.py b/agent/message_metadata.pyindex 7764b29da6c..7eb8cf12ec9 100644--- a/agent/message_metadata.py+++ b/agent/message_metadata.py@@ -7,6 +7,8 @@ from time import time as wall_timefrom uuid import uuid4from typing import Any, List, Mapping, MutableMapping, Optional, TypeVar+from agent.conversation_compression_archive import MERGED_DURABLE_ROWS, UNNAMED_DURABLE_ROWS+# These fields describe Hermes' durable record and timeline display, not# provider-visible message content. The request builder strips them from every@@ -42,7 +44,9 @@ PERSISTENCE_ONLY_MESSAGE_FIELDS = frozenset(# to sweep underscore keys, but turn_context.py pops this set from every outgoing copy and a strict# backend 400s on any key it does not know.{"timestamp", "display_kind", "display_metadata", "_row_id", "_submit_row_session_id",- MERGED_TURN_PREFIX, MESSAGE_UID, ABSORBED_MESSAGE_UIDS, TOOL_CALL_UIDS, TOOL_CALL_UID}+ MERGED_TURN_PREFIX, MESSAGE_UID, ABSORBED_MESSAGE_UIDS, TOOL_CALL_UIDS, TOOL_CALL_UID,+ # The alternation repair's row counts: an in-place compaction reads them off the live dict.+ MERGED_DURABLE_ROWS, UNNAMED_DURABLE_ROWS}) | REPAIR_BOOKKEEPING_FIELDSdiff --git a/tests/agent/test_in_place_merged_user_rows.py b/tests/agent/test_in_place_merged_user_rows.pyindex 3ba5e7e5d28..2fb171e7161 100644--- a/tests/agent/test_in_place_merged_user_rows.py+++ b/tests/agent/test_in_place_merged_user_rows.py@@ -68,3 +68,25 @@ def test_compaction_over_an_unanswered_prompt_keeps_one_copy_of_every_row(sessio"SELECT COUNT(*) FROM messages WHERE session_id = 'sid' AND active = 1"" AND (role = 'tool' OR tool_calls IS NOT NULL)").fetchone()[0] == 0assert [c.split(" ")[0] for c in live[-2:]] == ["U15", "A15"]+++def test_the_repair_row_counts_stay_off_the_request_copy(session):+ """The commit reads the counts off the live dict. A transport is handed the request copy, and+ one that forwards unknown keys must not find them there."""+ from agent.conversation_compression_archive import MERGED_DURABLE_ROWS, UNNAMED_DURABLE_ROWS+ from agent.turn_context import build_api_messages++ db, agent = session+ _turn(db, agent, SimpleNamespace(conversation_history=[]), "cli", 1, 5_000)+ for role, content, fields in KILLED_TURN_LEFT["two_prompts_tool_call"]:+ db.append_message("sid", role, content, **fields)+ history = db.get_messages_as_conversation("sid", repair_alternation=True)+ counts = {MERGED_DURABLE_ROWS, UNNAMED_DURABLE_ROWS}+ assert counts <= set(history[-1]) # two prompts merged, and the tool call dropped behind them++ request, _ = build_api_messages(+ agent, history, current_turn_user_idx=len(history) - 1,+ ext_prefetch_cache="", plugin_user_context="", moa_config=None, active_system_prompt="")++ assert not any(counts & set(message) for message in request)+ assert counts <= set(history[-1])