Repository navigation
fix(bot-mode): DMs to a Desktop-owned Bot Chat land in the live session instead of being dropped (#100523) - #101293
Merged
Merged
Conversation
…on instead of being dropped (#100523) When the Desktop has a bot's "Bot Chat" open, that session holds the single-owner lease, so the `hermes -p <bot> chat -c "Bot Chat"` subprocess `bot_relay.deliver` spawns refuses with "already has a live owner" and the DM payload is dropped — the sender was already acked. bot_relay.deliver now looks up a live in-process session for the target profile whose title resolves to "Bot Chat" (same profile_home match as session.resume's _find_live_unpersisted, pending_title for lazy sessions, otherwise the db title) and, when found, submits the message through the existing prompt.submit handler — the composer's choke point — so it lands as a normal user turn (role alternation preserved, streams to the open window). No live owner → the subprocess path runs exactly as before. On the local message_agent subprocess path, the lease refusal is surfaced as a structured `target_busy` delivery failure telling the sender the message was NOT delivered, instead of a raw exit-1 with the text buried in stderr. Closes #100523 Supersedes #100544, #100542 Co-authored-by: fangliquanflq <fangliquan@qq.com> Co-authored-by: 686f6c61 <github@00b.tech>
…ver interrupts the one in flight
teknium1
force-pushed
the
fix/bot-dm-delivers-into-live-bot-chat
branch
from
September 2, 2026 13:06
33eb5a1 to
5575ee2
Compare
૮ >ﻌ< ა ci reviewran on 5575ee2 — fix(bot-relay): a DM into a live Bot Chat queues as the next
|
This was referenced Sep 2, 2026
12 of 19 tasks
This was referenced Sep 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #100523: a Bot Mode DM sent to a teammate whose canonical "Bot Chat" is open on the Desktop was silently dropped. The Desktop-hosted session holds the single-owner lease, so the one-turn
hermes -p <bot> chat -c "Bot Chat"subprocess thatbot_relay.deliverspawns refused withalready has a live owner, exited 1, and the payload was gone — while the sender had already been acked "sent".Reworks #100544 (@fangliquanflq — routing-into-the-live-session insight) and #100542 (@686f6c61 — first claimant) down to the minimal in-process fix. Both authors carry
Co-authored-by:trailers on the commit.Changes
tui_gateway/methods_bot_relay.py—bot_relay.deliver: before spawning the subprocess, look up a live in-process session for the target profile whose title resolves toBot Chat(sameprofile_homestring compare assession.resume's_find_live_unpersisted;pending_titlefor lazy sessions, db title otherwise via_session_live_title). If found, submit the message through the existingprompt.submithandler — the composer's choke point — so it lands as a normal user turn (role alternation preserved, no synthetic injection, streams to the open window) and return ok. No live owner → the subprocess path runs exactly as before. Helper is nested in the handler per the method_ctx rebinding rule. (+32)tools/bot_mode_dm.py— localmessage_agentsubprocess path: when the CLI's stderr carries the lease refusal, emit a structured{"error": "... NOT delivered ...", "reason": "target_busy"}payload so the sender learns the message did not land, instead of a raw exit-1 with the text buried in stderr. (+11)test_deliver_lands_in_live_bot_chat_instead_of_subprocess(live Bot Chat → prompt.submit used, subprocess never spawned; a live session with another title → subprocess as before) andtest_delivery_runner_surfaces_live_owner_refusal.Validation
pytest tests/tui_gateway/test_bot_relay_methods.py tests/tools/test_bot_mode_dm.py→ 49 passed, 1 skipped. Sabotage run (fix stashed, tests kept): exactly the two new tests fail.ruff checkclean on all four files.uvicorn+/api/ws, isolatedHERMES_HOME, real provider creds, profilebeta). A WS client didsession.create {profile: beta, title: "Bot Chat"}+ one real turn (holding the session live), thenbot_relay.deliver {profile: beta, message: "[relay from @alpha] ping-100523: reply with the word PONG only."}was called over the same socket. — before (origin/main):{"code": 5092, "message": "delivery turn failed: Session 20260902_051449_f1607d already has a live owner (tui, pid 3424374, running 2m)..."}and beta's transcript stayed atuser: Reply with exactly the word OK / assistant: OK— payload dropped; after (this branch):{"reply": "Delivered into @beta's open Bot Chat; the reply will appear there."}and beta'sstate.dbtranscript gaineduser: [relay from @alpha] ping-100523 ... / assistant: PONG— the DM landed as a normal user turn and the agent answered in the live session.Closes #100523
Supersedes #100544, #100542
Infographic