fix(gateway): preserve archived compaction history on /retry rewrite (#80216) - #80695
fix(gateway): preserve archived compaction history on /retry rewrite (#80216)#80695RelaxJonh wants to merge 1 commit into
Conversation
rewrite_transcript() called replace_messages() with the default active_only=False, which DELETEd every row for the session — including soft-archived (active=0) compaction turns that in-place compaction deliberately keeps on disk for searchable history. After any /retry on a compacted session, the archived pre-compaction history was gone permanently: hard ID gaps, empty archive queries, missing in_place_committed history. Nothing was logged. Fix: probe has_archived_messages() before the rewrite and pass active_only=True when archives exist, mirroring the ACP adapter's _persist and the TUI prompt.submit path after NousResearch#80195. Fixes NousResearch#80216
|
#80218 already fixes #80216 with a regression test and is linked from the issue. One design note for reviewers: this PR moves the probe inside rewrite_transcript, which changes behavior for every caller of the shared method (yuanbao recall, compress rotation). That auto-preserve shape was rejected in #57803 in favor of per-caller guards, and the probe variant has the fail-open/TOCTOU failure mode already discussed and fixed on #80218. Also worth saying gently: with ~19.5k open PRs, every duplicate of an already-claimed issue costs real maintainer triage time. The PR template asks contributors to search existing PRs before opening one, and this issue has had a linked fix PR since before this one was created. |
|
Closing as a duplicate of #80218, which fixes the same bug (#80216) and was filed earlier by the issue reporter. Both PRs correctly identified the root cause —
Thanks for the correct diagnosis and the fix — appreciated even though the other PR won the tiebreak! |
Summary
rewrite_transcript()calledreplace_messages()with the defaultactive_only=False, which DELETEd every row for the session — including soft-archived (active=0) compaction turns that in-place compaction deliberately keeps on disk for searchable history.After any
/retryon a compacted session, the archived pre-compaction history was gone permanently: hard ID gaps, empty archive queries, missingin_place_committedhistory. Nothing was logged.Root Cause
gateway/slash_commands.py:2587(_handle_retry_command):gateway/session.pyrewrite_transcriptthen called:with
active_onlydefaulting toFalse, so the DELETE had noactiveclause and took the archived rows with it.Fix
Probe
has_archived_messages()before the rewrite and passactive_only=Truewhen archives exist, mirroring the ACP adapter's_persistand the TUIprompt.submitpath after #80195.Testing
has_archived_messagesmethod exists onSessionDB(line 7130 ofhermes_state.py)False, soactive_only=False— same as before)Fixes #80216