The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: make /busy command available on gateway platforms
Abdias Joelc64feb23f322
diff --git a/gateway/run.py b/gateway/run.pyindex 08c379fbc9e..85ad9266dbe 100644--- a/gateway/run.py+++ b/gateway/run.py@@ -18459,6 +18459,9 @@ class GatewayRunner(GatewayAuthorizationMixin, GatewayKanbanWatchersMixin, Gatewif canonical == "approvals":return await self._handle_approvals_command(event)+ if canonical == "busy":+ return await self._handle_busy_command(event)+if canonical == "model":return await self._handle_model_command(event)diff --git a/gateway/slash_commands.py b/gateway/slash_commands.pyindex f8b2d854f4b..2cd55f21ea1 100644--- a/gateway/slash_commands.py+++ b/gateway/slash_commands.py@@ -4244,6 +4244,63 @@ class GatewaySlashCommandsMixin:logger.warning("Failed to save tool_progress mode: %s", e)return f"{descriptions[new_mode]}\n" + t("gateway.verbose.save_failed", error=e)+ async def _handle_busy_command(self, event: MessageEvent) -> Union[str, EphemeralReply]:+ """Handle /busy — control what happens when messaging while Hermes is working.++ Usage:+ /busy Show current busy input mode+ /busy status Show current busy input mode+ /busy queue Queue messages for the next turn+ /busy steer Inject messages mid-run without interrupting+ /busy interrupt Interrupt the current run (default)+ """+ text = (event.text or "").strip()+ parts = text.split(maxsplit=1)+ if len(parts) < 2 or parts[1].strip().lower() == "status":+ mode = self._busy_input_mode+ if mode == "queue":+ behavior = "queues for next turn"+ elif mode == "steer":+ behavior = "steers into current run (after next tool call)"+ else:+ behavior = "interrupts current run"+ return EphemeralReply(+ f"**Busy input mode: `{mode}`**\n"+ f"Messages while busy: _{behavior}_\n"+ f"Change with `/busy queue`, `/busy steer`, or `/busy interrupt`."+ )++ arg = parts[1].strip().lower()+ if arg not in {"queue", "interrupt", "steer"}:+ return EphemeralReply(+ f"Unknown mode `{arg}`. Use `/busy queue`, `/busy steer`, or `/busy interrupt`."+ )++ # Persist before mutate — prevents divergent state when save fails+ try:+ from cli import save_config_value+ if save_config_value("display.busy_input_mode", arg):+ self._busy_input_mode = arg+ if arg == "queue":+ behavior = "Messages will be queued for the next turn while Hermes is busy."+ elif arg == "steer":+ behavior = "Messages will be steered into the current run (after the next tool call)."+ else:+ behavior = "Messages will interrupt the current run while Hermes is busy."+ return EphemeralReply(+ f"Busy input mode set to **`{arg}`** (saved).\n"+ f"_{behavior}_"+ )+ else:+ return EphemeralReply(+ f"Busy input mode could not be saved to config. Mode unchanged."+ )+ except Exception as e:+ logger.warning("Failed to save busy_input_mode: %s", e)+ return EphemeralReply(+ f"Could not save busy input mode: {e}. Mode unchanged."+ )+async def _handle_footer_command(self, event: MessageEvent) -> str:"""Handle /footer command — toggle the runtime-metadata footer.diff --git a/hermes_cli/commands.py b/hermes_cli/commands.pyindex 9619072473d..f5e76c926c6 100644--- a/hermes_cli/commands.py+++ b/hermes_cli/commands.py@@ -311,9 +311,9 @@ COMMAND_REGISTRY: list[CommandDef] = [cli_only=True, args_hint="[on|off|status]",subcommands=("on", "off", "status")),CommandDef("busy", "Control what Enter does while Hermes is working", "Configuration",- cli_only=True, args_hint="[queue|steer|interrupt|status]",+ args_hint="[queue|steer|interrupt|status]",subcommands=("queue", "steer", "interrupt", "status"),- desktop="terminal"),+ busy_policy="dispatch", desktop="terminal"),# Tools & SkillsCommandDef("tools", "Manage tools: /tools [list|disable|enable] [name...]", "Tools & Skills",diff --git a/tests/gateway/test_busy_command.py b/tests/gateway/test_busy_command.pynew file mode 100644index 00000000000..d08ad55923f--- /dev/null+++ b/tests/gateway/test_busy_command.py@@ -0,0 +1,66 @@+"""Smoke tests for gateway /busy command dispatch."""++import pytest++import gateway.run as gateway_run+from gateway.config import Platform+from gateway.platforms.base import EphemeralReply, MessageEvent+from gateway.session import SessionSource+++def _make_runner(busy_mode="interrupt"):+ """Create a GatewayRunner with known busy mode."""+ runner = object.__new__(gateway_run.GatewayRunner)+ runner.session_store = None+ runner.config = None+ runner._busy_input_mode = busy_mode+ return runner+++def _make_event(text: str, chat_id: str = "chat-test") -> MessageEvent:+ source = SessionSource(+ platform=Platform.TELEGRAM,+ user_id=f"user-{chat_id}",+ chat_id=chat_id,+ user_name="tester",+ chat_type="dm",+ )+ return MessageEvent(text=text, source=source)+++class TestBusyCommand:+ """Test /busy command dispatch without config persistence."""++ @pytest.mark.asyncio+ async def test_status_returns_current_mode(self):+ """/busy status shows the current busy mode."""+ runner = _make_runner(busy_mode="queue")+ event = _make_event("/busy status")+ result = await runner._handle_busy_command(event)+ assert "queue" in str(result).lower()++ @pytest.mark.asyncio+ async def test_bare_busy_shows_status(self):+ """/busy without arguments shows status."""+ runner = _make_runner(busy_mode="steer")+ event = _make_event("/busy")+ result = await runner._handle_busy_command(event)+ assert "steer" in str(result).lower()++ @pytest.mark.asyncio+ async def test_busy_invalid_arg(self):+ """/busy with invalid arg returns error."""+ runner = _make_runner()+ event = _make_event("/busy bananas")+ result = await runner._handle_busy_command(event)+ assert "unknown" in str(result).lower()++ @pytest.mark.asyncio+ async def test_busy_toggle_messages(self):+ """Status response includes the mode and behavior."""+ runner = _make_runner(busy_mode="queue")+ event = _make_event("/busy status")+ result = await runner._handle_busy_command(event)+ reply_text = str(result)+ assert "queue" in reply_text.lower()+ assert "busy" in reply_text.lower()