fix(state): heal alternation at the ACP / CLI-resume / TUI-resume restore sites too
Follow-up to the restore-boundary alternation heal (#65492): get_messages_ as_conversation grew a repair_alternation flag, wired into gateway load_transcript and the CLI startup resume. Three other LIVE-REPLAY restore sites still loaded the transcript verbatim, so a durable 'user;user' violation there re-fires the pre-request defensive repair on every request for the rest of the session (it only ever mutates the per-request list, never the restored working conversation): - acp_adapter/session.py::SessionManager._restore — the loaded history becomes the resumed ACP (Zed) agent's SessionState.history. - hermes_cli/cli_commands_mixin.py — the /resume slash command sets self.conversation_history from the load (the startup resume was fixed, this mid-session one was missed). - tui_gateway/server.py — the resume handler feeds the load into the deferred session record's working conversation. Pass repair_alternation=True at all three so the wedge is healed once at restore. Inspection/export consumers (trace upload, context guard, api_server history, display_history) keep the verbatim default. Adds an end-to-end regression test driving the ACP _restore path: a seeded user;user session restores to an alternation-clean live history with no user input lost.
This commit is contained in:
@@ -534,9 +534,15 @@ class SessionManager:
|
||||
|
||||
model = row.get("model") or None
|
||||
|
||||
# Load conversation history.
|
||||
# Load conversation history. repair_alternation: this restore feeds
|
||||
# LIVE REPLAY — the loaded list becomes the resumed agent's working
|
||||
# conversation. A durable ``user;user`` violation left in state.db would
|
||||
# otherwise re-fire the pre-request defensive repair on every request
|
||||
# for the rest of the session (see hermes_state.get_messages_as_conversation).
|
||||
try:
|
||||
history = db.get_messages_as_conversation(session_id)
|
||||
history = db.get_messages_as_conversation(
|
||||
session_id, repair_alternation=True
|
||||
)
|
||||
except Exception:
|
||||
logger.warning("Failed to load messages for ACP session %s", session_id, exc_info=True)
|
||||
history = []
|
||||
|
||||
Reference in New Issue
Block a user