The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): block resume during active turns
Mohamad Kansoa3cd00cae505
diff --git a/hermes_cli/cli_commands_mixin.py b/hermes_cli/cli_commands_mixin.pyindex 4de01f0d360..1569d9268fd 100644--- a/hermes_cli/cli_commands_mixin.py+++ b/hermes_cli/cli_commands_mixin.py@@ -1261,6 +1261,8 @@ class CLICommandsMixin:# ---- /resume, /sessions, /branch ------------------------------------------------------def _handle_resume_command(self, cmd_original: str) -> None:"""Handle /resume <session_id_or_title> — switch to a previous session mid-conversation."""+ if getattr(self, "_agent_running", False):+ return _cp(" Agent is busy. Wait for the current turn to finish, then retry /resume.")from cli import _sync_process_session_idtarget = _command_arg(cmd_original)# Users copy the help text's placeholder brackets/quotes verbatim (``/resume <abc123>``).diff --git a/tests/hermes_cli/test_resume_mid_turn_guard.py b/tests/hermes_cli/test_resume_mid_turn_guard.pynew file mode 100644index 00000000000..5967a1c636b--- /dev/null+++ b/tests/hermes_cli/test_resume_mid_turn_guard.py@@ -0,0 +1,38 @@+"""regression tests for refusing /resume during an active agent turn."""++import sys+from types import SimpleNamespace++from hermes_cli import cli_commands_mixin+++def _make_cli(agent_running: bool):+ cli = object.__new__(cli_commands_mixin.CLICommandsMixin)+ cli._agent_running = agent_running+ cli._session_db = None+ cli._pending_resume_sessions = None+ return cli+++def test_resume_refuses_mid_turn(monkeypatch):+ printed = []+ monkeypatch.setattr(cli_commands_mixin, "_cp", lambda *lines: printed.extend(lines))+ cli = _make_cli(agent_running=True)++ cli._handle_resume_command("/resume previous-session")++ assert printed == [+ " Agent is busy. Wait for the current turn to finish, then retry /resume."+ ]+++def test_resume_keeps_existing_idle_behavior(monkeypatch):+ printed = []+ monkeypatch.setattr(cli_commands_mixin, "_cp", lambda *lines: printed.extend(lines))+ monkeypatch.setitem(sys.modules, "cli", SimpleNamespace(_sync_process_session_id=lambda *a, **k: None))+ cli = _make_cli(agent_running=False)++ cli._handle_resume_command("/resume previous-session")++ assert printed+ assert "busy" not in " ".join(printed).lower()