From 42b9b0ae8a83fe2d1957baeeb4bc524bf0a8516b Mon Sep 17 00:00:00 2001 From: OpenBot Date: Tue, 13 Oct 2026 17:50:24 +0800 Subject: [PATCH] =?UTF-8?q?feat(inbound):=20tell=20user=20when=20chat=20ha?= =?UTF-8?q?s=20no=20binding=20=E2=80=94=20routing=20never=20silent?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First message on an unbound chat now shows which default agent will handle it (+ /agents, /switch hints) before the turn runs. --- src/agenthub/channels/wecom.py | 5 +++-- src/agenthub/runtime.py | 11 ++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/agenthub/channels/wecom.py b/src/agenthub/channels/wecom.py index 0500a59..a583c31 100644 --- a/src/agenthub/channels/wecom.py +++ b/src/agenthub/channels/wecom.py @@ -133,8 +133,9 @@ class WecomAibotChannel: continue msg = json.loads(raw) cmd = msg.get("cmd", "") - if cmd: # skip ack/pong frames (no cmd? actually acks have no cmd) - self._logger.info(f"[wecom] recv cmd={cmd} chatid={(msg.get('body') or {}).get('chatid')} msgtype={(msg.get('body') or {}).get('msgtype')}") + keys = sorted(msg.keys()) + if "aibot_msg_callback" in raw or "chatid" in raw: + self._logger.info(f"[wecom] recv keys={keys} cmd={cmd} chatid={(msg.get('body') or msg).get('chatid')} msgtype={(msg.get('body') or msg).get('msgtype')} text={str((msg.get('body') or msg).get('text'))[:60]}") try: self._dispatch(msg, ws) except Exception as e: # noqa: BLE001 diff --git a/src/agenthub/runtime.py b/src/agenthub/runtime.py index 86642c0..4b5e33c 100644 --- a/src/agenthub/runtime.py +++ b/src/agenthub/runtime.py @@ -124,7 +124,16 @@ def _safe_inbound(mgr: SessionManager, ch, m) -> None: if res is not None: _safe_event(ch, f"{ch.name}:{m.chat_id}", "command_result", res) return - # 3) normal prompt + # 3) binding visibility: no binding yet -> tell the user which + # agent WILL handle this chat (auto-bound on first turn), so + # routing is never silent/mysterious + if mgr.get_binding(ch.name, m.chat_id) is None: + default = mgr._default_agent() + mgr._emit(f"{ch.name}:{m.chat_id}", "status", { + "text": f"当前会话尚未绑定 agent,将由默认 agent「{default}」处理" + "(如需指定其他 agent,回复 /agents 查看、/switch <名> 切换)。", + }) + # 4) normal prompt mgr.prompt(ch.name, m.chat_id, m.text, images=m.images) except Exception as e: # noqa: BLE001 import logging