Skip to content

The agent that grows with you

fix(cli): the paused-chat notice after a restart says what happened and what to type

Teknium3f96f7f81dce
diff --git a/hermes_cli/cli_chat_turn_mixin.py b/hermes_cli/cli_chat_turn_mixin.py
index bdf19d2373c..76b6e5489fb 100644
--- a/hermes_cli/cli_chat_turn_mixin.py
+++ b/hermes_cli/cli_chat_turn_mixin.py
@@ -532,7 +532,7 @@ class CLIChatTurnMixin:
except GatewayClientError as exc:
_cprint(f" /discard: {exc}")
return
- _cprint(f" Discarded {lost['admission_id']}; send your prompt again.")
+ _cprint(" Dropped the unfinished turn. Send your message again.")
def _chat_render_turn(self, turn, agent_thread, interrupt_msg):
"""Post-turn display: errors, interrupt marker, reasoning/response panels, bell, re-queues.
diff --git a/hermes_cli/gateway_agent.py b/hermes_cli/gateway_agent.py
index fce0bea2925..ddcb6eacbf4 100644
--- a/hermes_cli/gateway_agent.py
+++ b/hermes_cli/gateway_agent.py
@@ -863,7 +863,8 @@ class GatewayAgent:
self.connection.reattach(turn.session_id, abandon=self._stop(turn))
self.connection.start()
self._sync_show_reasoning()
- return self._lost_turn_notice()
+ notice = self._lost_turn_notice()
+ return f"Your message was not sent.\n{notice}" if notice else ""
def _lost_turn_notice(self):
from hermes_cli.gateway_chat_view import pending_lines
diff --git a/hermes_cli/gateway_chat_view.py b/hermes_cli/gateway_chat_view.py
index 2cbcbbb1124..9b7f62796b0 100644
--- a/hermes_cli/gateway_chat_view.py
+++ b/hermes_cli/gateway_chat_view.py
@@ -23,11 +23,12 @@ def _pending_preview(text):
line = " ".join("".join(ch if ch.isprintable() else " " for ch in strip_ansi(text)).split())
if len(line) > _PREVIEW_CHARS:
line = line[:_PREVIEW_CHARS - 1] + "…"
- return f": {line}" if line else ""
+ return f' "{line}"' if line else ""
-_UNKNOWN_OUTCOME = ("Execution outcome is unknown. Resume this session to inspect the lost turn "
- "and /discard it; do not resend the input.")
+_UNKNOWN_OUTCOME = ("Hermes restarted before this turn finished, so how far it got is unknown. "
+ "Resume this session to check, then type /discard to drop it. "
+ "Don't send the same message again until you've checked.")
_BLOCKING_CONTROL_EVENTS = frozenset({
"approval.request", "approval.settled", "clarify.request", "clarify.settled",
@@ -36,19 +37,34 @@ _BLOCKING_CONTROL_EVENTS = frozenset({
def pending_lines(pending):
- """The owner's pending admissions as shown on attach (the classic CLI shows them before a turn)."""
- unknown = any(row["status"] == "unknown" for row in pending)
- lines = ["Execution outcome unknown after restart. Discard acknowledges the lost turn "
- "without replaying it; queued work may then continue."] if unknown else []
- for row in pending:
- admission = row["admission_id"]
- # A queued prompt is not in the transcript yet: show what is about to run (or was lost).
- preview = _pending_preview(row.get("text"))
- if row["status"] == "unknown":
- lines.append(f"Unknown admission: {admission}{preview}\n/discard {admission}")
- elif row["status"] == "queued":
- context = "waiting behind unknown work" if unknown else "waiting to run"
- lines.append(f"Queued admission: {admission} ({context}){preview}")
+ """The owner's pending admissions as shown on attach (the classic CLI shows them before a turn).
+ A lost turn is never replayed, so the person must be told what it was and the exact command
+ that drops it; a queued prompt is not in the transcript yet, so it is quoted too."""
+ lost = [row for row in pending if row["status"] == "unknown"]
+ queued = [row for row in pending if row["status"] == "queued"]
+ lines = []
+ if lost:
+ one = len(lost) == 1
+ lines.append("⏸ This chat is paused. Hermes restarted while "
+ + ("a turn was running, so it never finished:" if one
+ else f"{len(lost)} turns were running, so they never finished:"))
+ why = (f" Hermes won't re-run {'it' if one else 'them'} by itself, since {'it' if one else 'they'} "
+ "may already have done part of the work.")
+ if one:
+ lines.extend(line for line in (_pending_preview(lost[0].get("text")), why,
+ " To drop it and continue, type:",
+ f"/discard {lost[0]['admission_id']}") if line)
+ else:
+ lines.append(f"{why} To drop one and continue, type the /discard line under it:")
+ for row in lost:
+ preview = _pending_preview(row.get("text"))
+ lines.append(f"{preview}\n/discard {row['admission_id']}" if preview
+ else f"/discard {row['admission_id']}")
+ if queued:
+ count = "1 message is" if len(queued) == 1 else f"{len(queued)} messages are"
+ lines.append(f" {count} waiting and will run after that:" if lost
+ else f" {count} waiting to run:")
+ lines.extend(_pending_preview(row.get("text")) or " (no text)" for row in queued)
return lines
@@ -452,8 +468,9 @@ class GatewayChatView:
self.completions[admission] = {"outcome": "unknown", "text": _UNKNOWN_OUTCOME}
return None
if own == "queued" and self.unknown_admissions():
- return ("Unknown execution blocks this session; your accepted input is retained. "
- "Resume interactively to resolve the lost turn; do not resend the input.")
+ return ("This chat is paused behind a turn that never finished when Hermes restarted. "
+ "Your message is saved and will run once you resume this session and /discard "
+ "that turn; don't send it again.")
if self.prompts and (own or not self.gaps): # a control blocks only a turn still pending
return "Input required; detached without cancelling. Resume this session interactively."
return None
diff --git a/tests/hermes_cli/test_gateway_chat_pending_preview.py b/tests/hermes_cli/test_gateway_chat_pending_preview.py
index 4665fff971b..44394ef58f7 100644
--- a/tests/hermes_cli/test_gateway_chat_pending_preview.py
+++ b/tests/hermes_cli/test_gateway_chat_pending_preview.py
@@ -25,11 +25,10 @@ def test_resume_lists_pending_admission_text_capped_and_terminal_safe(capsys):
err = capsys.readouterr().err
lines = err.splitlines()
- unknown = next(line for line in lines if "adm-unknown" in line and "Unknown" in line)
- queued = next(line for line in lines if "adm-queued" in line)
assert "/discard adm-unknown" in lines
- assert "summarise the logs" in unknown
- assert "deploy hidden" in queued and "now xxx" in queued
- preview = queued.split(": ", 2)[-1]
+ assert any("summarise the logs" in line for line in lines)
+ queued = next(line for line in lines if "deploy hidden" in line)
+ assert "now xxx" in queued
+ preview = queued.strip().strip('"')
assert len(preview) <= 80 and preview.endswith("…")
assert not [ch for ch in err if ch != "\n" and not ch.isprintable()], repr(err)
diff --git a/tests/hermes_cli/test_gateway_chat_view_replay_gap.py b/tests/hermes_cli/test_gateway_chat_view_replay_gap.py
index 7f09716ae48..0fb15fed66f 100644
--- a/tests/hermes_cli/test_gateway_chat_view_replay_gap.py
+++ b/tests/hermes_cli/test_gateway_chat_view_replay_gap.py
@@ -100,7 +100,7 @@ async def test_unknown_row_settles_the_interactive_turn(capsys):
return view.failure
view, failure = await gapped(answer, interactive)
assert failure is None and view.completions["a"]["outcome"] == "unknown"
- assert "outcome is unknown" in capsys.readouterr().out
+ assert "how far it got is unknown" in capsys.readouterr().out
@pytest.mark.asyncio
diff --git a/tests/hermes_cli/test_gateway_queued_unknown.py b/tests/hermes_cli/test_gateway_queued_unknown.py
index d2ffd2ceecb..303c3df28e8 100644
--- a/tests/hermes_cli/test_gateway_queued_unknown.py
+++ b/tests/hermes_cli/test_gateway_queued_unknown.py
@@ -44,7 +44,7 @@ async def test_finite_follower_does_not_wait_forever_after_worker_loss(before_ac
assert len(peer.calls) == 1
assert peer.calls[0][1]['text'] == 'queued'
output = capsys.readouterr()
- assert 'accepted input is retained' in output.err and 'do not resend' in output.err
+ assert 'Your message is saved' in output.err and "don't send it again" in output.err
if stream_json:
records = [json.loads(line) for line in output.out.splitlines()]
assert records[-1]['type'] == 'result' and records[-1]['exit_code'] == 3
@@ -100,4 +100,4 @@ async def test_own_lost_turn_exits_from_its_unknown_completion_not_queued_detach
view = GatewayChatView(Peer(), {'stored_session_id': 's'}, quiet=True)
assert await asyncio.wait_for(view.run('work', oneshot=True), 5) == 1
- assert 'accepted input is retained' not in capsys.readouterr().err
+ assert 'Your message is saved' not in capsys.readouterr().err