feat(archivar): Telemetrie um STAY/UNSICHER/TIMEOUT-Unterscheidung erweitern

Auftrag t_5e4863c6 — Routing-Telemetrie differenziert jetzt:
- llm_stay_sicher  — LLM sagte STAY (sicher), kein Red Flag, kein Cloud-Call
- llm_unsicher     — LLM sagte UNSICHER, Red Flag (Cloud-Call)
- llm_timeout      — LLM timeoutete (separat von llm_unavailable)
- cloud_call_stay  — Cloud-Agent endete mit STAY (Cloud-Call ohne Routing-Effekt)
- cloud_call_route — Cloud-Agent entschied ROUTE (Cloud-Call mit Wirkung)
- no_llm_needed    — Nachricht vor Stufe 4 entschieden (FAISS/Keyword/Smalltalk)

Abwärtskompatibel: llm_stay und llm_unavailable bleiben unverändert.
::status zeigt die neuen Zähler in einer Routing-Telemetrie-Sektion.
10 neue Tests (test_telemetry_stay_unsicher_timeout.py).
This commit is contained in:
Bernd (Hermes)
2026-09-02 15:36:05 +02:00
parent 21b1fd4e13
commit 00aecfaa7b
5 changed files with 355 additions and 2 deletions
+10 -1
View File
@@ -1101,6 +1101,7 @@ class BidirectionalRouter:
text[:80], matched_room.name,
)
routing_counter.increment('keyword_100_auto_route')
routing_counter.increment('no_llm_needed')
routing_telemetry.record(
stage='keyword_100', score=1.0, decision='route',
target=matched_room.room_id, origin=origin_room_id,
@@ -1125,6 +1126,7 @@ class BidirectionalRouter:
text[:80], matched_room.name,
)
routing_counter.increment('keyword_context_butler')
routing_counter.increment('no_llm_needed')
routing_telemetry.record(
stage='context_keyword', score=0.95, decision='butler',
target=matched_room.room_id, origin=origin_room_id,
@@ -1212,6 +1214,7 @@ class BidirectionalRouter:
booster_applied,
)
routing_counter.increment('faiss_auto_route')
routing_counter.increment('no_llm_needed')
routing_telemetry.record(
stage='faiss', score=top_score, decision='route',
target=top_room_id, origin=origin_room_id,
@@ -1243,6 +1246,7 @@ class BidirectionalRouter:
FAISS_AUTO_ROUTE,
)
routing_counter.increment('faiss_butler')
routing_counter.increment('no_llm_needed')
routing_telemetry.record(
stage='faiss', score=top_score, decision='butler',
target=top_room_id, origin=origin_room_id,
@@ -1267,6 +1271,7 @@ class BidirectionalRouter:
)
if is_smalltalk:
routing_counter.increment('no_llm_needed')
return RoutingDecision(
category="smalltalk",
target_room="",
@@ -1319,6 +1324,7 @@ class BidirectionalRouter:
"100%% Keyword-Match (4.5): '%s' → %s — Auto-Route (kein Butler)",
text[:80], matched_room.name,
)
routing_counter.increment('no_llm_needed')
return RoutingDecision(
category="work_order",
target_room=matched_room.room_id,
@@ -1336,6 +1342,7 @@ class BidirectionalRouter:
"Kontext-Keyword-Match (4.5): '%s' → %s — Butler fragt",
text[:80], matched_room.name,
)
routing_counter.increment('no_llm_needed')
return RoutingDecision(
category="work_order",
target_room=matched_room.room_id,
@@ -1438,7 +1445,7 @@ class BidirectionalRouter:
)
routing_counter.increment('llm_unsicher')
routing_telemetry.record(
stage='llm', score=0.0, decision='stay',
stage='llm', score=0.0, decision='unsicher',
target='', origin=origin_room_id,
duration_ms=routing_telemetry.elapsed_ms(),
)
@@ -1470,6 +1477,7 @@ class BidirectionalRouter:
"LLM-Raum-Router: STAY für '%.80s...' → stay_in_room", text[:80]
)
routing_counter.increment('llm_stay')
routing_counter.increment('llm_stay_sicher')
routing_telemetry.record(
stage='llm', score=0.0, decision='stay',
target='', origin=origin_room_id,
@@ -1696,6 +1704,7 @@ class BidirectionalRouter:
LLM_ROOM_LOOKUP_TIMEOUT, text,
)
routing_counter.increment('llm_room_lookup_timeout')
routing_counter.increment('llm_timeout')
routing_counter.record_attempt(success=False)
return None, False, True, "unavailable", ""
except Exception as e: