fix(session): use second-level timestamp granularity in legacy dedup key
The _normalized_message_timestamp_for_key helper was preserving microsecond precision (%.6f). When the same message is persisted by both the WebUI sidecar JSON writer and the Hermes agent state.db writer, their timestamps can differ by a few microseconds, causing _session_message_merge_key to produce different keys for the same logical message and letting both copies survive the dedup pass in merge_session_messages_append_only. Truncating to second-level granularity collapses sub-second drift to the same key, so the duplicate is suppressed correctly. Fixes #2616
This commit is contained in:
parent
9c983e693a
commit
ff0aa69d5f
1 changed files with 4 additions and 3 deletions
|
|
@ -2495,9 +2495,10 @@ def _normalized_message_timestamp_for_key(value):
|
|||
timestamp = float(value)
|
||||
except (TypeError, ValueError):
|
||||
return str(value)
|
||||
if timestamp.is_integer():
|
||||
return str(int(timestamp))
|
||||
return ("%.6f" % timestamp).rstrip("0").rstrip(".")
|
||||
# Truncate to second-level granularity so that sub-second drift between
|
||||
# the sidecar JSON write and the state.db created_at write does not cause
|
||||
# the legacy dedup key to differ for the same logical message.
|
||||
return str(int(timestamp))
|
||||
|
||||
|
||||
def _message_timestamp_as_float(msg):
|
||||
|
|
|
|||
Loading…
Reference in a new issue