Skip to content

The agent that grows with you

fix(bot-relay): a DM into a live Bot Chat queues as the next turn, never interrupts the one in flight

Teknium0058bde251fe
diff --git a/tests/tui_gateway/test_bot_relay_methods.py b/tests/tui_gateway/test_bot_relay_methods.py
index f4090598ff8..85b18d971a7 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 e2e2e277fa4..50445187590 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(