feat(inbound): tell user when chat has no binding — routing never silent
First message on an unbound chat now shows which default agent will handle it (+ /agents, /switch hints) before the turn runs.
This commit is contained in:
1 parent
69ea08ad44
commit
42b9b0ae8a
2 files changed
+13
-3
No files matched your search
@@ -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
|
||||
|
||||
+10
-1
@@ -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
|
||||
|
||||
Reference in new issue
Block a user