fix(compression): preserve steer display identity

(cherry picked from commit a8570878bc848a42cc8029fc45219a57e76be4c4)
This commit is contained in:
fangliquan
2026-09-20 18:04:48 +08:00
committed by Teknium
parent 6d02101fbf
commit bb9058d7e8
3 changed files with 48 additions and 1 deletions

View File

@@ -515,6 +515,11 @@ class SessionMessagesMixin:
message_timestamp = _coerce_timestamp(msg.get("timestamp"), now_ts)
cur = conn.execute(_INSERT_MESSAGE_SQL, self._message_row_params(
session_id, role, msg, tool_calls, message_timestamp, keep_reasoning=role == "assistant"))
# Keep the caller's live row aligned with the durable identity. Rows created without an explicit
# timestamp (notably mid-turn steers) may be carried through several compaction generations; if
# the generated timestamp exists only in SQLite, every copy receives a new identity and renders
# as another logical message.
msg["timestamp"] = message_timestamp
if cur.lastrowid is not None:
msg["_row_id"] = cur.lastrowid
inserted += 1