From 0058bde251fe891547b4a35c61e48ff8a9b4b908 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Wed, 2 Sep 2026 06:06:02 -0700 Subject: [PATCH] fix(bot-relay): a DM into a live Bot Chat queues as the next turn, never interrupts the one in flight --- tests/tui_gateway/test_bot_relay_methods.py | 3 ++- tui_gateway/methods_bot_relay.py | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/tui_gateway/test_bot_relay_methods.py b/tests/tui_gateway/test_bot_relay_methods.py index f4090598ff..85b18d971a 100644 --- a/tests/tui_gateway/test_bot_relay_methods.py +++ b/tests/tui_gateway/test_bot_relay_methods.py @@ -127,7 +127,8 @@ def test_deliver_lands_in_live_bot_chat_instead_of_subprocess(home, monkeypatch) {"profile_home": str(home / "profiles" / "ops"), "pending_title": "Bot Chat", "history": []}, ) out = _result(srv._methods["bot_relay.deliver"](1, {"profile": "ops", "message": "ping"})) - assert submitted == [{"session_id": "live-ops", "text": "ping"}] + # queued=True is the invariant: a DM never interrupts a turn in flight. + assert submitted == [{"session_id": "live-ops", "text": "ping", "queued": True}] assert not spawned assert "reply" in out diff --git a/tui_gateway/methods_bot_relay.py b/tui_gateway/methods_bot_relay.py index e2e2e277fa..5044518759 100644 --- a/tui_gateway/methods_bot_relay.py +++ b/tui_gateway/methods_bot_relay.py @@ -133,7 +133,10 @@ def _(rid, params: dict) -> dict: live_sid = _live_bot_chat_sid(resolved) if live_sid: - submitted = _methods["prompt.submit"](rid, {"session_id": live_sid, "text": message}) + # queued=True: a teammate's DM runs as the NEXT turn. It must never + # interrupt or steer a turn already in flight (the default busy + # mode does); hundreds of arrivals simply queue in arrival order. + submitted = _methods["prompt.submit"](rid, {"session_id": live_sid, "text": message, "queued": True}) if "error" in submitted: return submitted return _ok(