From 738c977e7dc8aefe233ef5111b7819ec5f8eb70f Mon Sep 17 00:00:00 2001 From: OpenBot Date: Tue, 13 Oct 2026 17:25:01 +0800 Subject: [PATCH] fix(session): switch() persists binding; wecom dispatch errors logged MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - switch() (admin UI bind + /switch) never called _persist_binding — UI-created bindings were lost on restart and invisible in the db - wecom ws recv loop swallowed dispatch exceptions silently; now logs msg preview on dispatch failure (inbound blind spot) --- src/agenthub/channels/wecom.py | 5 ++++- src/agenthub/session.py | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/agenthub/channels/wecom.py b/src/agenthub/channels/wecom.py index 16572f5..83aa31c 100644 --- a/src/agenthub/channels/wecom.py +++ b/src/agenthub/channels/wecom.py @@ -132,7 +132,10 @@ class WecomAibotChannel: if raw is None: continue msg = json.loads(raw) - self._dispatch(msg, ws) + try: + self._dispatch(msg, ws) + except Exception as e: # noqa: BLE001 + self._logger.error(f"[wecom] dispatch failed: {e}; msg={raw[:200]}") finally: try: ws.close() diff --git a/src/agenthub/session.py b/src/agenthub/session.py index eecd3dc..d6e8c10 100644 --- a/src/agenthub/session.py +++ b/src/agenthub/session.py @@ -244,6 +244,7 @@ class SessionManager: self._bindings[self.key(channel, chat_id)] = Binding( channel=channel, chat_id=chat_id, agent=agent_name, acp_session_id=session_id ) + self._persist_binding(self._bindings[self.key(channel, chat_id)]) for entry in migrated: self._append_text(key, agent_name, session_id, entry) return {"agent": agent_name, "acp_session_id": session_id, "migrated": len(migrated)}