From e3f9ee31f41b253f25b480af307f5009e72c0c3e Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Sat, 6 Jun 2026 08:42:11 +0200 Subject: [PATCH] feat(archivar): Route-Antwort in Zielraum + Notiz im Ursprungsraum --- plugin/adapter.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/plugin/adapter.py b/plugin/adapter.py index a3bdeb8..7777e37 100644 --- a/plugin/adapter.py +++ b/plugin/adapter.py @@ -572,6 +572,7 @@ class RocketChatAdapter(BasePlatformAdapter): # ── Archivar-Klassifikation ────────────────────────────────── # Klassifiziere die Nachricht und reichere den Context an category = "" + decision = None try: decision = await self.archivar.handle_and_forward(text, origin_room_id=room_id, message_id=msg_id) if decision and decision.category: @@ -579,6 +580,15 @@ class RocketChatAdapter(BasePlatformAdapter): except Exception as e: logger.debug("[rocketchat] Archivar classification skipped: %s", e) + # Forward-Antwort-Umleitung + if decision and hasattr(decision, 'target_room') and decision.target_room and decision.target_room != room_id: + _CURRENT_ORIGIN_ROOM.set(decision.target_room) + try: + note_text = f"Ich antworte im {getattr(decision, 'matched_room_name', None) or 'Zielraum'}." + await self.send(room_id, note_text) + except Exception as e: + logger.debug("[rocketchat] Failed to send forward note: %s", e) + # ── Virtual Room Translation ───────────────────────────────── # Replace room-based chat_id with user-based virtual chat_id. # This collapses all rooms per user into ONE Hermes session: @@ -587,7 +597,9 @@ class RocketChatAdapter(BasePlatformAdapter): # Both get the same session key. virtual_chat_id = f"user:{username}" # Track the REAL room for send() to route the response back - _CURRENT_ORIGIN_ROOM.set(room_id) + # Only set if no forwarding occurred + if not (decision and hasattr(decision, 'target_room') and decision.target_room and decision.target_room != room_id): + _CURRENT_ORIGIN_ROOM.set(room_id) # Ensure this user→room mapping is recorded for proaktive sends if virtual_chat_id not in self._user_rooms: