fix: LLM-Timeout 15s — qwen2.5:7b auf CPU braucht 9s, 3s war zu kurz

This commit is contained in:
Bernd (Hermes)
2026-07-27 17:38:06 +02:00
parent d265624f1c
commit 407014db98
4 changed files with 37 additions and 37 deletions
+18 -18
View File
@@ -1578,12 +1578,12 @@ class BidirectionalRouter:
# Try LLM — expects room ID directly or "STAY"
# Semaphore schützt vor parallelen Ollama-Aufrufen (qwen2.5:7b = single-request)
# P0-CRITICAL: Semaphore-Acquire mit 3s Timeout — muss KLEINER sein als
# der äußere 4s-Timeout in adapter.py.
# P0-CRITICAL: Semaphore-Acquire mit 18s Timeout — muss KLEINER sein als
# der äußere 20s-Timeout in adapter.py.
try:
await asyncio.wait_for(self._llm_semaphore.acquire(), timeout=3.0)
await asyncio.wait_for(self._llm_semaphore.acquire(), timeout=18.0)
except asyncio.TimeoutError:
logger.warning("LLM semaphore acquire timed out (3s) — skipping LLM room lookup")
logger.warning("LLM semaphore acquire timed out (18s) — skipping LLM room lookup")
return None, False, True # LLM-Aufruf fehlgeschlagen
try:
llm_result = await self._classifier._llm_raw(prompt)
@@ -1848,22 +1848,22 @@ class BidirectionalRouter:
old_topic=old_topic or "(kein altes Thema)",
)
# LLM-Aufruf mit 3s Timeout (Semaphore + LLM-Call)
# P0-CRITICAL: Semaphore-Acquire mit 3s Timeout — muss KLEINER sein als
# der äußere 4s-Timeout in adapter.py.
# LLM-Aufruf mit 18s Semaphore + 15s LLM-Call Timeout
# P0-CRITICAL: Semaphore-Acquire mit 18s Timeout — muss KLEINER sein als
# der äußere 20s-Timeout in adapter.py.
try:
await asyncio.wait_for(self._llm_semaphore.acquire(), timeout=3.0)
await asyncio.wait_for(self._llm_semaphore.acquire(), timeout=18.0)
except asyncio.TimeoutError:
logger.warning("V7-4: LLM-Semaphore Timeout (3s) → Fallback: NEU")
logger.warning("V7-4: LLM-Semaphore Timeout (18s) → Fallback: NEU")
return None
try:
try:
llm_result = await asyncio.wait_for(
self._classifier._llm_raw(prompt),
timeout=3.0,
timeout=15.0,
)
except asyncio.TimeoutError:
logger.warning("V7-4: LLM-Check Timeout (3s) → Fallback: NEU")
logger.warning("V7-4: LLM-Check Timeout (15s) → Fallback: NEU")
return None
except Exception as e:
logger.warning("V7-4: LLM-Check fehlgeschlagen: %s → Fallback: NEU", e)
@@ -2207,25 +2207,25 @@ async def validate_sentence_marker(
v7_3_state=v7_3_state,
)
# ── LLM-Aufruf mit 3s Timeout (Semaphore + LLM-Call) ──────────────
# P0-CRITICAL: Semaphore-Acquire mit 3s Timeout — muss KLEINER sein als
# der äußere 4s-Timeout in adapter.py.
# ── LLM-Aufruf mit 18s Semaphore + 15s LLM-Call Timeout ──────────
# P0-CRITICAL: Semaphore-Acquire mit 18s Timeout — muss KLEINER sein als
# der äußere 20s-Timeout in adapter.py.
try:
await asyncio.wait_for(llm_semaphore.acquire(), timeout=3.0)
await asyncio.wait_for(llm_semaphore.acquire(), timeout=18.0)
except asyncio.TimeoutError:
logger.warning(
"A1b Stufe 4/5: LLM-Semaphore Timeout (3s) → Fallback: unentscheidbar"
"A1b Stufe 4/5: LLM-Semaphore Timeout (18s) → Fallback: unentscheidbar"
)
return None
try:
try:
llm_result = await asyncio.wait_for(
classifier._llm_raw(prompt),
timeout=3.0,
timeout=15.0,
)
except asyncio.TimeoutError:
logger.warning(
"A1b Stufe 4/5: LLM-Validierung Timeout (3s) → Fallback: unentscheidbar"
"A1b Stufe 4/5: LLM-Call Timeout (15s) → Fallback: unentscheidbar"
)
return None
except Exception as e: