fix: V8.5 — DM-Bypass differenziert: 100%-Keywords in DMs erkannt + Butler Move-Request (R8)
This commit is contained in:
@@ -467,8 +467,70 @@ class BidirectionalRouter:
|
||||
confidence=1.0,
|
||||
stay_in_room=True,
|
||||
)
|
||||
logger.debug("DM-Guard V8.2: origin_room_id leer → DM-Routing erlaubt (A4)")
|
||||
# Kein sofortiges stay_in_room — normaler Flow mit Butler
|
||||
|
||||
# ── V8.5: DM-Routing differenziert ──────────────────────
|
||||
# Stufe 0 (100%-Keywords): IMMER ausführen, auch in DMs.
|
||||
# 100%-Keyword-Treffer → Move-Request (Butler-Prinzip).
|
||||
# Kein 100%-Treffer → Catch-All (LLM antwortet im DM).
|
||||
# FAISS + weiche Keywords: in DMs NICHT ausführen.
|
||||
routing_telemetry.start_timer()
|
||||
matched_room = self._room_map.find_room_by_keywords(text, origin_room_id=None)
|
||||
if matched_room is not None:
|
||||
is_100 = self._room_map.is_100_percent_match(text, matched_room)
|
||||
if is_100:
|
||||
# 100%-Keyword in DM → Butler (Move-Request vorschlagen)
|
||||
logger.info(
|
||||
"DM 100%% Keyword-Match: '%s' → %s — Butler (Move-Request)",
|
||||
text[:80], matched_room.name,
|
||||
)
|
||||
routing_counter.increment('dm_100_keyword_butler')
|
||||
routing_telemetry.record(
|
||||
stage='dm_100_keyword', score=1.0, decision='butler',
|
||||
target=matched_room.room_id, origin=origin_room_id,
|
||||
duration_ms=routing_telemetry.elapsed_ms(),
|
||||
)
|
||||
logger.info("ROUTING DECISION: reason=dm_100_keyword_butler, origin_room=%s, target_room=%s, stay=False, butler_mode=True", origin_room_id, matched_room.room_id)
|
||||
matched_keywords = self._extract_matched_keywords(text, matched_room)
|
||||
room_name = matched_room.name.replace("#", "") if matched_room.name.startswith("#") else matched_room.name
|
||||
notification = f"📋 Bearbeite ich in #{room_name} — [Link]"
|
||||
return RoutingDecision(
|
||||
category="work_order",
|
||||
target_room=matched_room.room_id,
|
||||
confidence=0.95,
|
||||
matched_room_name=matched_room.name,
|
||||
source_room_notification=notification,
|
||||
matched_keywords=matched_keywords,
|
||||
move_request_sent=True, # Butler-Prinzip: vorschlagen, nicht automatisch
|
||||
move_request_target_name=matched_room.name,
|
||||
move_request_target_id=matched_room.room_id,
|
||||
)
|
||||
else:
|
||||
# Kontext-Keyword in DM → Catch-All (kein Routing)
|
||||
logger.info(
|
||||
"DM Kontext-Keyword-Match: '%s' → %s — Catch-All (kein Routing in DM)",
|
||||
text[:80], matched_room.name,
|
||||
)
|
||||
routing_counter.increment('dm_context_catch_all')
|
||||
logger.info("ROUTING DECISION: reason=dm_context_catch_all, origin_room=%s, target_room=, stay=True, butler_mode=False", origin_room_id)
|
||||
return RoutingDecision(
|
||||
category="direct_question",
|
||||
target_room="",
|
||||
confidence=0.0,
|
||||
is_catch_all=True,
|
||||
stay_in_room=True,
|
||||
)
|
||||
else:
|
||||
# Kein Keyword-Match in DM → Catch-All
|
||||
logger.debug("DM: Kein Keyword-Match → Catch-All")
|
||||
routing_counter.increment('dm_no_match_catch_all')
|
||||
logger.info("ROUTING DECISION: reason=dm_no_match_catch_all, origin_room=%s, target_room=, stay=True, butler_mode=False", origin_room_id)
|
||||
return RoutingDecision(
|
||||
category="direct_question",
|
||||
target_room="",
|
||||
confidence=0.0,
|
||||
is_catch_all=True,
|
||||
stay_in_room=True,
|
||||
)
|
||||
|
||||
# ── Schritt 0: Excluded rooms check ──────────────────────────
|
||||
if origin_room_id and self._room_map.is_excluded(origin_room_id):
|
||||
|
||||
Reference in New Issue
Block a user