From ae878e1aeeaf8241d8c88c0fa8d3b2e25728950c Mon Sep 17 00:00:00 2001 From: HexLab98 Date: Tue, 7 Jul 2026 03:06:40 +0700 Subject: [PATCH] fix(state): set active=1 explicitly in message INSERTs (#51646) append_message() and _insert_message_rows() relied on the schema DEFAULT for messages.active. Legacy databases that gained the column via ALTER TABLE without a working INSERT default can store active=NULL, which makes get_messages_as_conversation()'s active=1 filter drop every gateway turn. --- hermes_state.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hermes_state.py b/hermes_state.py index a2895b09c7a..0a506c85a49 100644 --- a/hermes_state.py +++ b/hermes_state.py @@ -3465,8 +3465,8 @@ class SessionDB: """INSERT INTO messages (session_id, role, content, tool_call_id, tool_calls, tool_name, timestamp, token_count, finish_reason, reasoning, reasoning_content, reasoning_details, codex_reasoning_items, - codex_message_items, platform_message_id, observed) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""", + codex_message_items, platform_message_id, observed, active) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""", ( session_id, role, @@ -3484,6 +3484,7 @@ class SessionDB: codex_message_items_json, platform_message_id, 1 if observed else 0, + 1, ), ) msg_id = cursor.lastrowid @@ -3556,8 +3557,8 @@ class SessionDB: """INSERT INTO messages (session_id, role, content, tool_call_id, tool_calls, tool_name, timestamp, token_count, finish_reason, reasoning, reasoning_content, reasoning_details, codex_reasoning_items, - codex_message_items, platform_message_id, observed) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""", + codex_message_items, platform_message_id, observed, active) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)""", ( session_id, role, @@ -3575,6 +3576,7 @@ class SessionDB: codex_message_items_json, platform_msg_id, 1 if msg.get("observed") else 0, + 1, ), ) inserted += 1