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>
This commit is contained in:
Teknium 2026-03-20 09:44:27 -07:00 committed by GitHub
parent 0e3b7b6a39
commit 66a1942524
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 31 additions and 0 deletions

View file

@ -1369,6 +1369,23 @@ class GatewayRunner:
del self._running_agents[_quick_key]
return await self._handle_reset_command(event)
# /queue <prompt> — queue without interrupting
if event.get_command() in ("queue", "q"):
queued_text = event.get_command_args().strip()
if not queued_text:
return "Usage: /queue <prompt>"
adapter = self.adapters.get(source.platform)
if adapter:
from gateway.platforms.base import MessageEvent as _ME, MessageType as _MT
queued_event = _ME(
text=queued_text,
message_type=_MT.TEXT,
source=event.source,
message_id=event.message_id,
)
adapter._pending_messages[_quick_key] = queued_event
return "Queued for the next turn."
if event.message_type == MessageType.PHOTO:
logger.debug("PRIORITY photo follow-up for session %s — queueing without interrupt", _quick_key[:20])
adapter = self.adapters.get(source.platform)