fix(adapter): Antwort-Routing — _CURRENT_ORIGIN_ROOM hat Vorrang vor Archivar-Target
This commit is contained in:
+14
-9
@@ -614,7 +614,7 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
for rid, info in self._room_info.items()
|
||||
}
|
||||
missing = self.archivar.check_room_map_completeness(subscribed_with_types)
|
||||
if missing:
|
||||
if missing and _MULTIROOM():
|
||||
await self._start_onboarding(missing)
|
||||
except Exception as e:
|
||||
logger.warning("[rocketchat] Archivar-Initialisierung fehlgeschlagen: %s — Fallback ohne Klassifikation", e)
|
||||
@@ -1239,6 +1239,7 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
"operator_room_id": operator_room_id,
|
||||
"skipped_rooms": [], # room_ids die übersprungen wurden
|
||||
}
|
||||
if _MULTIROOM() and self.archivar is not None:
|
||||
self.archivar._stats["onboarding_active"] = True
|
||||
|
||||
# Baue Nachricht mit Emoji-Nummern-Referenzen
|
||||
@@ -1329,6 +1330,7 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
await self._post_message_with_retry(operator_room_id, "❌ Bitte eine Raumnummer (1, 2, …) oder 'überspringen' eingeben.")
|
||||
return # onboarding_active bleibt True
|
||||
# Catch-All-Frage beantwortet → Onboarding wirklich abschließen
|
||||
if self.archivar is not None:
|
||||
self.archivar._stats["onboarding_active"] = False
|
||||
self._onboarding_state = {}
|
||||
logger.info("[rocketchat] Onboarding v2 vollständig abgeschlossen")
|
||||
@@ -1354,6 +1356,7 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
|
||||
if "later" in action:
|
||||
# Onboarding pausieren
|
||||
if self.archivar is not None:
|
||||
self.archivar._stats["onboarding_active"] = False
|
||||
self._onboarding_state = {}
|
||||
await self._post_message_with_retry(operator_room_id,
|
||||
@@ -1373,6 +1376,7 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
|
||||
if "Später" in action or "⏰" in action:
|
||||
# Onboarding pausieren
|
||||
if self.archivar is not None:
|
||||
self.archivar._stats["onboarding_active"] = False
|
||||
self._onboarding_state = {}
|
||||
await self._post_message_with_retry(operator_room_id,
|
||||
@@ -1718,18 +1722,19 @@ class RocketChatAdapter(BasePlatformAdapter):
|
||||
# We must resolve it to a real Rocket.Chat room_id for REST API.
|
||||
real_room_id = chat_id
|
||||
if chat_id.startswith("user:"):
|
||||
# Priority 0: Archivar-Kontext — wenn der Archivar einen thematischen
|
||||
# Zielraum gesetzt hat, geht die Antwort dorthin (Agent-Autonomie).
|
||||
thematic_target = _THEMATIC_TARGET_ROOM.get()
|
||||
if thematic_target and thematic_target != _CURRENT_ORIGIN_ROOM.get():
|
||||
real_room_id = thematic_target
|
||||
logger.debug("[rocketchat] send via Archivar target: %s → %s", chat_id, real_room_id)
|
||||
else:
|
||||
# Priority 1: ContextVar from the message that triggered this turn
|
||||
# Priority 0: _CURRENT_ORIGIN_ROOM — Antwort geht IMMER dorthin,
|
||||
# wo die Frage gestellt wurde.
|
||||
origin = _CURRENT_ORIGIN_ROOM.get()
|
||||
if origin:
|
||||
real_room_id = origin
|
||||
logger.debug("[rocketchat] send via ContextVar: %s → %s", chat_id, real_room_id)
|
||||
else:
|
||||
# Priority 1: Archivar-Kontext — nur für proaktive Nachrichten
|
||||
# ohne vorherige Frage (kein _CURRENT_ORIGIN_ROOM gesetzt).
|
||||
thematic_target = _THEMATIC_TARGET_ROOM.get()
|
||||
if thematic_target:
|
||||
real_room_id = thematic_target
|
||||
logger.debug("[rocketchat] send via Archivar target: %s → %s", chat_id, real_room_id)
|
||||
else:
|
||||
# Priority 2: proaktive Nachricht — use most recent room for this user
|
||||
rooms = self._user_rooms.get(chat_id, [])
|
||||
|
||||
Reference in New Issue
Block a user