From 3fe2dd832e97c781b6b5f5d9ef9d1581d4d47098 Mon Sep 17 00:00:00 2001 From: "Bernd (Hermes)" Date: Wed, 17 Jun 2026 22:01:45 +0200 Subject: [PATCH] =?UTF-8?q?fix(archivar):=20correct=20Coroutine-Bug=20root?= =?UTF-8?q?=20cause=20=E2=80=94=20=5Fllm=5Fraw=5Fsync=E2=86=92async=20=5Fl?= =?UTF-8?q?lm=5Fraw,=20direct=20await?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit OllamaLLMClient.generate() is async def — run_in_executor cannot correctly execute async functions. The coroutine was never awaited. Also fix Move-Request parser: native button '1️⃣ Rüber' was not matched against '1️⃣' — fell through to 'stay' instead of 'move'. - classifier.py: _llm_raw_sync → async _llm_raw, await generate() - router.py: remove run_in_executor, direct await _llm_raw() - adapter.py: normalize MOVE_REQ choice (extract leading digit/emoji) --- plugin/adapter.py | 5 +++++ plugin/archivar/classifier.py | 6 ++++-- plugin/archivar/router.py | 5 +---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/plugin/adapter.py b/plugin/adapter.py index fe65365..2ed96a2 100644 --- a/plugin/adapter.py +++ b/plugin/adapter.py @@ -743,6 +743,11 @@ class RocketChatAdapter(BasePlatformAdapter): if choice.startswith("MOVE_REQ:") and "::" in choice: _, choice = choice.split("::", 1) choice = choice.strip() + # Normalisiere: "1️⃣ Rüber" → "1️⃣", "2 Hier" → "2" + if choice and choice[0] in "123": + choice = choice[0] + elif choice and choice[:2] in ("1️⃣", "2️⃣", "3️⃣"): + choice = choice[:2] # Altes Format: "1"/"2"/"3" = numerische Antwort # Neues Format: "1️⃣", "2️⃣", "3️⃣" = Emoji-Nummern elif choice in ("1", "2", "3") or choice in ("1️⃣", "2️⃣", "3️⃣"): diff --git a/plugin/archivar/classifier.py b/plugin/archivar/classifier.py index 539526c..7568841 100644 --- a/plugin/archivar/classifier.py +++ b/plugin/archivar/classifier.py @@ -481,13 +481,15 @@ class IntentClassifier: logger.warning("LLM classification failed: %s", e) return None - def _llm_raw_sync(self, prompt: str) -> Optional[str]: + async def _llm_raw(self, prompt: str) -> Optional[str]: """Send a raw prompt to the LLM and return its response. Unlike ``_llm_classify_sync``, this does NOT validate against Intent-Kategorien. Uses ``LLMClient.generate()`` for free-form output. Used by the router for LLM_ROOM_PROMPT. + Async because OllamaLLMClient.generate() is async. + Args: prompt: The complete prompt to send. @@ -497,7 +499,7 @@ class IntentClassifier: try: if not self._llm_client or not self._llm_enabled: return None - return self._llm_client.generate(prompt) + return await self._llm_client.generate(prompt) except Exception as e: logger.warning("LLM raw call failed: %s", e) return None diff --git a/plugin/archivar/router.py b/plugin/archivar/router.py index 2ea9989..275d05c 100644 --- a/plugin/archivar/router.py +++ b/plugin/archivar/router.py @@ -598,10 +598,7 @@ class BidirectionalRouter: # Try LLM — expects room ID directly # Semaphore schützt vor parallelen Ollama-Aufrufen (qwen2.5:7b = single-request) async with self._llm_semaphore: - loop = asyncio.get_running_loop() - llm_result = await loop.run_in_executor( - None, self._classifier._llm_raw_sync, prompt - ) + llm_result = await self._classifier._llm_raw(prompt) if llm_result is None: return None, True # LLM-Aufruf fehlgeschlagen