The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(sessions): keep the settled-trigger skip, register the columns in the schema history, strip message_uid at the transport
Eva27d0ad63999e
diff --git a/agent/transports/chat_completions.py b/agent/transports/chat_completions.pyindex d2cab147770..3bbf012dc1f 100644--- a/agent/transports/chat_completions.py+++ b/agent/transports/chat_completions.py@@ -35,7 +35,7 @@ _XAI_TOOL_SEARCH_ALIAS = "hermes_tool_search"# providers reject with HTTP 400 ("Extra inputs are not permitted")._STRIP_MSG_KEYS = ("codex_reasoning_items", "codex_message_items", "tool_name", "effect_disposition", "timestamp",- "platform_message_id", "api_content", "anthropic_content_blocks", "bedrock_content_blocks",+ "platform_message_id", "api_content", "anthropic_content_blocks", "bedrock_content_blocks", "message_uid",)_STRIP_TC_KEYS = ("call_id", "response_item_id")_HIGH_EFFORTS = {"high", "xhigh", "max", "ultra"}diff --git a/hermes_cli/session_schema_history.py b/hermes_cli/session_schema_history.pyindex ef5c9b4e7d0..56ea44efae5 100644--- a/hermes_cli/session_schema_history.py+++ b/hermes_cli/session_schema_history.py@@ -239,6 +239,12 @@ SCHEMA_HISTORY: dict[str, _TableHistory] = {('+', 'display_identity', 'display_metadata'),('+', 'display_order', 'display_identity'),)),+ ('16 2026-09-28T08:42Z 20d67ffb5e', (('+', 'message_uid', 'display_order'),)),+ ('17 2026-09-28T08:50Z 0bc05f2656', (('+', 'absorbed_message_uids', 'message_uid'),)),+ ('18 2026-09-28T08:56Z aa49c0f597', (+ ('+', 'tool_call_uids', 'absorbed_message_uids'),+ ('+', 'tool_call_uid', 'tool_call_uids'),+ )),),),"session_model_usage": _TableHistory(diff --git a/hermes_state_common.py b/hermes_state_common.pyindex a6c456caef3..94599de8e45 100644--- a/hermes_state_common.py+++ b/hermes_state_common.py@@ -623,12 +623,13 @@ CREATE INDEX IF NOT EXISTS idx_messages_display_backfillCREATE INDEX IF NOT EXISTS idx_messages_display_identityON messages(session_id, display_identity, display_order)WHERE display_identity IS NOT NULL AND (active = 1 OR compacted = 1);--- Every row carries a message_uid, whoever wrote it: a build that predates the column inserts NULL, so the--- store mints one on its behalf (the current build always binds a uid, so this never fires for it).DROP TRIGGER IF EXISTS messages_message_uid_insert;CREATE TRIGGER IF NOT EXISTS messages_message_uid_insertAFTER INSERT ON messages WHEN new.message_uid IS NULLBEGIN+ -- Every row carries a message_uid, whoever wrote it: a build that predates the column binds NULL, so+ -- the store mints one on its behalf (the current build always binds a uid; this never fires for it).+ -- The note lives inside the body: a comment before DROP/CREATE would defeat the settled-trigger skip.UPDATE messages SET message_uid = lower(hex(randomblob(16))) WHERE id = new.id;END;DROP TRIGGER IF EXISTS messages_display_order_insert;diff --git a/tests/agent/test_compression_rotation_state.py b/tests/agent/test_compression_rotation_state.pyindex d94553a94c0..3a9643a6553 100644--- a/tests/agent/test_compression_rotation_state.py+++ b/tests/agent/test_compression_rotation_state.py@@ -1466,7 +1466,7 @@ class TestTodoSnapshotScaffoldingTails:{k: vfor k, v in m.items()- if k not in {"_row_id", "timestamp", _DB_PERSISTED_MARKER, DB_ROW_SNAPSHOT}+ if k not in {"_row_id", "timestamp", "message_uid", _DB_PERSISTED_MARKER, DB_ROW_SNAPSHOT}}for m in compressed] == expecteddiff --git a/tests/hermes_state/test_fts_trigram_cron_exclusion.py b/tests/hermes_state/test_fts_trigram_cron_exclusion.pyindex 703d1247bb0..42ba2d16442 100644--- a/tests/hermes_state/test_fts_trigram_cron_exclusion.py+++ b/tests/hermes_state/test_fts_trigram_cron_exclusion.py@@ -9,6 +9,10 @@ import pytestfrom hermes_state import SessionDBfrom hermes_state_common import FTS_TRIGRAM_SQL, SCHEMA_VERSION+# The trigram cron-exclusion rebuild is the v30 data migration: a store one version behind IT, not one+# behind the current SCHEMA_VERSION (later migrations do not re-run it).+_PRE_TRIGRAM_EXCLUSION_VERSION = 29+@pytest.fixturedef db(tmp_path):@@ -125,7 +129,7 @@ def test_existing_external_layout_rebuilds_trigram_on_upgrade(tmp_path):cli_id = old.append_message("cli", role="user", content="交互迁移内容")cron_id = old.append_message("cron", role="user", content="定时迁移内容")assert _trigram_rowids(old) == {cli_id, cron_id}- old._conn.execute("UPDATE schema_version SET version = ?", (SCHEMA_VERSION - 1,))+ old._conn.execute("UPDATE schema_version SET version = ?", (_PRE_TRIGRAM_EXCLUSION_VERSION,))old._conn.commit()old.close()@@ -233,7 +237,7 @@ def test_partial_upgrade_view_does_not_skip_historical_rebuild(tmp_path):old._conn.execute(f"DROP TRIGGER IF EXISTS {name}")old._conn.execute("DROP VIEW messages_fts_trigram_src")old._conn.executescript(FTS_TRIGRAM_SQL)- old._conn.execute("UPDATE schema_version SET version = ?", (SCHEMA_VERSION - 1,))+ old._conn.execute("UPDATE schema_version SET version = ?", (_PRE_TRIGRAM_EXCLUSION_VERSION,))old._conn.commit()old.close()