stage-359: apply Opus SHOULD-FIX — symmetric runtime-field clearing on snapshot load-and-mark path

This commit is contained in:
Hermes Agent
2026-05-15 15:27:24 +00:00
parent 4c102eaad5
commit 75a2464821
2 changed files with 12 additions and 1 deletions
+1 -1
View File
@@ -30,7 +30,7 @@
- **PR #2293** by @franksong2702 (fixes #2237) — Docker startup no longer fails when a bind-mounted `~/.hermes/hermes-agent/.git/objects` tree contains read-only git object packs. The root init ownership pass now skips that git object subtree while still chowning the rest of `/home/hermeswebui`. macOS Docker Desktop bind mounts can now start WebUI without requiring writable ownership over agent git internals.
- **PR #2295** by @ai-ag2026 — Context-compression snapshot preservation now clears archived parent runtime fields (`active_stream_id`, `pending_user_message`, `pending_attachments`, `pending_started_at`) before saving the old session id. Pre-fix, a completed continuation session could leave its archived parent looking permanently active/running after compression (sidebar showed the parent as if it had a live in-flight turn). Continuation session's live state is restored from saved locals after the snapshot write so the active turn is not affected. Stage-359 maintainer fix integrated this runtime-clearing into the `_preserve_pre_compression_snapshot()` helper from #2285 — both PRs touch the same compression rotation block.
- **PR #2295** by @ai-ag2026 — Context-compression snapshot preservation now clears archived parent runtime fields (`active_stream_id`, `pending_user_message`, `pending_attachments`, `pending_started_at`) before saving the old session id. Pre-fix, a completed continuation session could leave its archived parent looking permanently active/running after compression (sidebar showed the parent as if it had a live in-flight turn). Continuation session's live state is restored from saved locals after the snapshot write so the active turn is not affected. Stage-359 maintainer fix integrated this runtime-clearing into the `_preserve_pre_compression_snapshot()` helper from #2285 — both PRs touch the same compression rotation block. Stage-359 Opus SHOULD-FIX applied inline: the second branch of `_preserve_pre_compression_snapshot()` (when an existing on-disk file is at-least-as-complete-as memory) now also clears runtime fields on the loaded snapshot before saving — keeps the contract symmetric so snapshot files never contain live runtime state even via the load-and-mark-only path.
- **PR #2296** by @Jordan-SkyLF — Offline/recovery banner now follows the active theme palette via `--warning-*` tokens instead of mixing warning colors with a hard-coded `--bg-1` fallback. Light/custom skins (Sienna, Poseidon, etc.) no longer show a banner that looks detached from the selected palette. Behavior-neutral: offline detection and recovery flow unchanged.
+11
View File
@@ -1657,6 +1657,17 @@ def _preserve_pre_compression_snapshot(s, old_sid: str) -> None:
snapshot = Session.load(old_sid)
if snapshot:
snapshot.pre_compression_snapshot = True
# Stage-359 Opus SHOULD-FIX: clear runtime fields on the loaded
# snapshot too. If the disk snapshot was last persisted while the
# parent was live, it could carry a stale active_stream_id /
# pending_* over to disk. The sidebar projection filters snapshot
# rows so this is latent today, but the contract should match the
# primary branch above so future readers can trust snapshot files
# to never contain live runtime state.
snapshot.active_stream_id = None
snapshot.pending_user_message = None
snapshot.pending_attachments = []
snapshot.pending_started_at = None
snapshot.save(touch_updated_at=False, skip_index=False)
logger.info(
"Marked pre-compression session %s as sidebar-hidden snapshot",