fix: Rainer-Quality-Loop — 4 Fixes (2 release-blockierend, 2 dringend)
D1 (RELEASE-BLOCKIEREND): Guard 2.5 — LLM schlägt excluded room vor router.py: Nach Guard 2 (Catch-All) prüft Guard 2.5 ob LLM-Raum excluded ist → stay_in_room. Verhindert Move-Request in excluded room. D2 (RELEASE-BLOCKIEREND): DMs können in Projekträume geroutet werden router.py: Schritt 0 DM-Guard VOR allem anderen. origin_room_id leer (DM) → sofort stay_in_room. DMs nie vom Routing betroffen. D3 (DRINGEND): Self-Match-Schutz in Schritt 3, 3.5, 4.5 router.py: Keyword-Match (Schritt 3), FAISS auto-route (Schritt 3.5), Keyword-Match vor LLM (Schritt 4.5) prüfen alle auf matched_room.room_id == origin_room_id → stay_in_room. D4 (DRINGEND): install.sh base_url-Löschung zu aggressiv install.sh: base_url mit openrouter nur löschen wenn _RC_PROVIDER == ollama-cloud. Bei explizitem openrouter bleibt sie.
This commit is contained in:
@@ -258,6 +258,21 @@ class BidirectionalRouter:
|
||||
text = text.strip()
|
||||
|
||||
try:
|
||||
# ── Schritt 0: DM-Guard (VOR allem anderen) ──────────────────
|
||||
# DMs haben origin_room_id=''. Der Origin-First Guard greift
|
||||
# nicht für DMs. LLM kann Projektraum vorschlagen → Guard 3 →
|
||||
# Move-Request im DM → Antwort landet in Projektraum statt DM.
|
||||
# DMs sollen nie vom Routing betroffen sein — sie bleiben IMMER
|
||||
# im DM. (Release-blockierend)
|
||||
if not origin_room_id:
|
||||
logger.debug("DM-Guard: origin_room_id leer → stay_in_room (DM)")
|
||||
return RoutingDecision(
|
||||
category="direct_question",
|
||||
target_room="",
|
||||
confidence=0.0,
|
||||
stay_in_room=True,
|
||||
)
|
||||
|
||||
# ── Schritt 0: Excluded rooms check ──────────────────────────
|
||||
if origin_room_id and self._room_map.is_excluded(origin_room_id):
|
||||
logger.debug(
|
||||
@@ -318,6 +333,21 @@ class BidirectionalRouter:
|
||||
# ── Schritt 3: Keyword-Match (aus RoomMap) ──────────────────
|
||||
matched_room = self._room_map.find_room_by_keywords(text, origin_room_id=origin_room_id)
|
||||
if matched_room is not None:
|
||||
# Self-Match-Schutz: Wenn Keyword-Match den Ursprungsraum
|
||||
# selbst trifft (z.B. 'RC' matched #RC und User ist bereits
|
||||
# in #RC), dann stay_in_room statt Routing.
|
||||
if matched_room.room_id == origin_room_id:
|
||||
logger.debug(
|
||||
"Keyword self-match: '%s' matched origin room %s → stay_in_room",
|
||||
text[:80], matched_room.name,
|
||||
)
|
||||
return RoutingDecision(
|
||||
category="direct_question",
|
||||
target_room="",
|
||||
confidence=0.0,
|
||||
stay_in_room=True,
|
||||
)
|
||||
|
||||
logger.debug(
|
||||
"Keyword match: '%s' → %s", text[:80], matched_room.name
|
||||
)
|
||||
@@ -360,6 +390,19 @@ class BidirectionalRouter:
|
||||
if top_score >= FAISS_AUTO_ROUTE:
|
||||
room = self._room_map.get_room_by_id(top_room_id)
|
||||
if room is not None:
|
||||
# Self-Match-Schutz: FAISS matched origin room
|
||||
if top_room_id == origin_room_id:
|
||||
logger.debug(
|
||||
"FAISS self-match: '%s' matched origin room %s → stay_in_room",
|
||||
text[:80], room.name,
|
||||
)
|
||||
return RoutingDecision(
|
||||
category="direct_question",
|
||||
target_room="",
|
||||
confidence=0.0,
|
||||
stay_in_room=True,
|
||||
)
|
||||
|
||||
room_name = (
|
||||
room.name.replace("#", "")
|
||||
if room.name.startswith("#")
|
||||
@@ -429,6 +472,19 @@ class BidirectionalRouter:
|
||||
if result is not None and result.category == "work_order" and result.confidence < 0.9:
|
||||
matched_room = self._room_map.find_room_by_keywords(text, origin_room_id=origin_room_id)
|
||||
if matched_room is not None:
|
||||
# Self-Match-Schutz (auch in Schritt 4.5)
|
||||
if matched_room.room_id == origin_room_id:
|
||||
logger.debug(
|
||||
"Keyword self-match (4.5): '%s' matched origin room %s → stay_in_room",
|
||||
text[:80], matched_room.name,
|
||||
)
|
||||
return RoutingDecision(
|
||||
category="direct_question",
|
||||
target_room="",
|
||||
confidence=0.0,
|
||||
stay_in_room=True,
|
||||
)
|
||||
|
||||
logger.info(
|
||||
"Keyword-Match vor LLM: '%s' → %s (embedding conf=%.3f)",
|
||||
text[:80], matched_room.name, result.confidence,
|
||||
@@ -508,6 +564,21 @@ class BidirectionalRouter:
|
||||
stay_in_room=True,
|
||||
)
|
||||
|
||||
# Guard 2.5: LLM == excluded room → stay_in_room
|
||||
# Verhindert, dass der LLM einen excluded room vorschlägt und
|
||||
# ein Move-Request dorthin gesendet wird (Release-blockierend).
|
||||
if self._room_map.is_excluded(llm_room.room_id):
|
||||
logger.warning(
|
||||
"Origin-First Guard: LLM schlug excluded room '%s' (%s) vor → stay_in_room",
|
||||
llm_room.name, llm_room.room_id[:8],
|
||||
)
|
||||
return RoutingDecision(
|
||||
category="direct_question",
|
||||
target_room="",
|
||||
confidence=0.0,
|
||||
stay_in_room=True,
|
||||
)
|
||||
|
||||
# Guard 3: LLM == anderer Raum → Move-Request (Butler-Prinzip)
|
||||
room_name = llm_room.name.replace("#", "") if llm_room.name.startswith("#") else llm_room.name
|
||||
logger.info(
|
||||
|
||||
Reference in New Issue
Block a user