The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(tui_gateway): busy refusals during a manual /compress say to wait, not Stop
kshitijk4poor21d19a42bc1d
diff --git a/tests/tui_gateway/test_busy_compression_demotion.py b/tests/tui_gateway/test_busy_compression_demotion.pyindex 3f0e01cddf6..1e024a58d71 100644--- a/tests/tui_gateway/test_busy_compression_demotion.py+++ b/tests/tui_gateway/test_busy_compression_demotion.py@@ -223,7 +223,9 @@ def test_submit_during_manual_compress_is_queued_and_reply_persists(monkeypatch)second = server._methods["session.compress"]("r3", {"session_id": "sid"}) # the locked claim maps to busyassert second["error"]["code"] == 4009# tools.configure rebuilds the agent (history_version bump): refused before it reads the action- assert server._methods["tools.configure"]("r4", {"session_id": "sid"})["error"]["code"] == 4009+ refused = server._methods["tools.configure"]("r4", {"session_id": "sid"})["error"]+ assert refused["code"] == 4009+ assert "/compress" in refused["message"] and "Stop" not in refused["message"] # nothing is replyingwith pytest.raises(server.CompressionBusy): # the /compress + slash-mirror core: a typed busy, not a failureserver._compress_live_with_feedback("sid", session, agent, "", snapshot_kwargs=True)# "/compress --aggressive" never touches history: answered without claiming (or draining) the busy sessiondiff --git a/tui_gateway/methods_session.py b/tui_gateway/methods_session.pyindex b133bdf0216..cd54dd0792e 100644--- a/tui_gateway/methods_session.py+++ b/tui_gateway/methods_session.py@@ -2019,7 +2019,7 @@ def _(rid, params: dict, session: dict) -> dict:@_session_method("session.undo", live=True)def _(rid, params: dict, session: dict) -> dict:# Under a running turn the post-run write would clobber the undo — stop the reply first.- busy = _err(rid, 4009, busy_message("undo"))+ busy = _err(rid, 4009, busy_message("undo", bool(session.get("_manual_compress_active"))))if session.get("running"):return busyremoved = 0diff --git a/tui_gateway/methods_slash.py b/tui_gateway/methods_slash.pyindex 9a10f940648..fae8a898922 100644--- a/tui_gateway/methods_slash.py+++ b/tui_gateway/methods_slash.py@@ -486,7 +486,7 @@ def _mirror_slash_side_effects(sid: str, session: dict, command: str) -> str:if _session_uses_compute_host(session):return _compute_host_slash(sid, session, name, command)[1]if session.get("running"):- return busy_message(name)+ return busy_message(name, bool(session.get("_manual_compress_active")))if (mirror := _SLASH_MIRRORS.get(name)) is None:return ""try:diff --git a/tui_gateway/methods_tools.py b/tui_gateway/methods_tools.pyindex 52c8f3763f7..1ab6a4c37b5 100644--- a/tui_gateway/methods_tools.py+++ b/tui_gateway/methods_tools.py@@ -140,7 +140,7 @@ def _mcp_config_server_or_error(rid, params):def _busy_error(rid, session, cmd: str):if session.get("running"):- return _err(rid, 4009, busy_message(cmd))+ return _err(rid, 4009, busy_message(cmd, bool(session.get("_manual_compress_active"))))return None@@ -1225,7 +1225,7 @@ def _(rid, params: dict, session) -> dict:# Full-history rollback mutates session history → rejected mid-turn (prompt.submit# would drop the agent's output or clobber it). File-scoped only touches disk.if not file_path and session.get("running"):- return _err(rid, 4009, busy_message("rollback restore"))+ return _err(rid, 4009, busy_message("rollback restore", bool(session.get("_manual_compress_active"))))def go(mgr, cwd):if reason := _container_checkpoint_refusal(session, mgr, cwd):diff --git a/tui_gateway/user_messages.py b/tui_gateway/user_messages.pyindex bbfdf274984..6e73065e996 100644--- a/tui_gateway/user_messages.py+++ b/tui_gateway/user_messages.py@@ -83,10 +83,13 @@ def turn_error_text(error: Any, surface: dict | None = None, *, recoverable: booreturn "\n".join(lines)-def busy_message(command: str) -> str:+def busy_message(command: str, compressing: bool = False) -> str:"""4009 refusal for a history-mutating command while a reply is streaming. There is no``/interrupt`` slash command on any client: Desktop has a Stop button, the terminal TUI uses- Ctrl+C — name both without assuming which one the reader has."""+ Ctrl+C — name both without assuming which one the reader has. A manual /compress also holds+ the session busy, but nothing is replying and Stop does not end it: say to wait instead."""+ if compressing:+ return f"session busy — a /compress is running; run /{command.lstrip('/')} when it finishes."return (f"session busy — Hermes is still replying. Stop the current reply first (Stop button, "f"or Ctrl+C in a terminal), then run /{command.lstrip('/')}.")