Skip to content

Commit 66a1942

Browse files
teknium1Test
andauthored
feat: add /queue command to queue prompts without interrupting (#2191)
Adds /queue <prompt> (alias /q) that queues a message for the next turn while the agent is busy, without interrupting the current run. - CLI: /queue <prompt> puts it in _pending_input for the next turn - Gateway: /queue <prompt> creates a pending MessageEvent on the adapter, picked up after the current agent run finishes - Enter still interrupts as usual (no behavior change) - /queue with no prompt shows usage - /queue when agent is idle tells user to just type normally Co-authored-by: Test <test@test.com>
1 parent 0e3b7b6 commit 66a1942

3 files changed

Lines changed: 31 additions & 0 deletions

File tree

cli.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3678,6 +3678,18 @@ def process_command(self, command: str) -> bool:
36783678
self._handle_stop_command()
36793679
elif canonical == "background":
36803680
self._handle_background_command(cmd_original)
3681+
elif canonical == "queue":
3682+
if not self._agent_running:
3683+
_cprint(" /queue only works while Hermes is busy. Just type your message normally.")
3684+
else:
3685+
# Extract prompt after "/queue " or "/q "
3686+
parts = cmd_original.split(None, 1)
3687+
payload = parts[1].strip() if len(parts) > 1 else ""
3688+
if not payload:
3689+
_cprint(" Usage: /queue <prompt>")
3690+
else:
3691+
self._pending_input.put(payload)
3692+
_cprint(f" Queued for the next turn: {payload[:80]}{'...' if len(payload) > 80 else ''}")
36813693
elif canonical == "skin":
36823694
self._handle_skin_command(cmd_original)
36833695
elif canonical == "voice":

gateway/run.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,6 +1369,23 @@ async def _handle_message(self, event: MessageEvent) -> Optional[str]:
13691369
del self._running_agents[_quick_key]
13701370
return await self._handle_reset_command(event)
13711371

1372+
# /queue <prompt> — queue without interrupting
1373+
if event.get_command() in ("queue", "q"):
1374+
queued_text = event.get_command_args().strip()
1375+
if not queued_text:
1376+
return "Usage: /queue <prompt>"
1377+
adapter = self.adapters.get(source.platform)
1378+
if adapter:
1379+
from gateway.platforms.base import MessageEvent as _ME, MessageType as _MT
1380+
queued_event = _ME(
1381+
text=queued_text,
1382+
message_type=_MT.TEXT,
1383+
source=event.source,
1384+
message_id=event.message_id,
1385+
)
1386+
adapter._pending_messages[_quick_key] = queued_event
1387+
return "Queued for the next turn."
1388+
13721389
if event.message_type == MessageType.PHOTO:
13731390
logger.debug("PRIORITY photo follow-up for session %s — queueing without interrupt", _quick_key[:20])
13741391
adapter = self.adapters.get(source.platform)

hermes_cli/commands.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ class CommandDef:
6767
gateway_only=True),
6868
CommandDef("background", "Run a prompt in the background", "Session",
6969
aliases=("bg",), args_hint="<prompt>"),
70+
CommandDef("queue", "Queue a prompt for the next turn (doesn't interrupt)", "Session",
71+
aliases=("q",), args_hint="<prompt>"),
7072
CommandDef("status", "Show session info", "Session",
7173
gateway_only=True),
7274
CommandDef("sethome", "Set this chat as the home channel", "Session",

0 commit comments

Comments
 (0)