fix: PresenceEngine Hotfix — decrement aus send() entfernt, INFO-Logging, stderr-Handler
This commit is contained in:
+12
-7
@@ -1620,6 +1620,8 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
self._presence_engine.set_current_room(room_name)
|
self._presence_engine.set_current_room(room_name)
|
||||||
self._presence_engine.increment_active_tasks()
|
self._presence_engine.increment_active_tasks()
|
||||||
self._presence_engine.update_presence()
|
self._presence_engine.update_presence()
|
||||||
|
logger.info("[presence] active_tasks++ → %d (room=%s)",
|
||||||
|
self._presence_engine._active_tasks, room_name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# ── R5: Inline-Command-Erkennung (VOR Onboarding + Hermes-Dispatch) ──
|
# ── R5: Inline-Command-Erkennung (VOR Onboarding + Hermes-Dispatch) ──
|
||||||
@@ -2795,6 +2797,8 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
self._presence_engine.update_presence()
|
self._presence_engine.update_presence()
|
||||||
# P1-2: current_room zurücksetzen nach Verarbeitung
|
# P1-2: current_room zurücksetzen nach Verarbeitung
|
||||||
self._presence_engine.set_current_room("")
|
self._presence_engine.set_current_room("")
|
||||||
|
logger.info("[presence] active_tasks-- → %d (turn complete)",
|
||||||
|
self._presence_engine._active_tasks)
|
||||||
|
|
||||||
# ── R5: Inline-Command-Handler ────────────────────────────────────────
|
# ── R5: Inline-Command-Handler ────────────────────────────────────────
|
||||||
|
|
||||||
@@ -6160,9 +6164,11 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
# ── B5v6.5: Conversation History — Agent-Antwort aufzeichnen ──
|
# ── B5v6.5: Conversation History — Agent-Antwort aufzeichnen ──
|
||||||
if _MULTIROOM() and self._conversation_history is not None:
|
if _MULTIROOM() and self._conversation_history is not None:
|
||||||
await self._conversation_history.add(real_room_id, "agent", content)
|
await self._conversation_history.add(real_room_id, "agent", content)
|
||||||
# ── V8.6: PresenceEngine — active_tasks-- nach Response ──
|
# ── V8.6 P1-3: PresenceEngine — KEIN decrement in send()! ──
|
||||||
self._presence_engine.decrement_active_tasks()
|
# Der Counter wird NUR im finally-Block von _process_incoming
|
||||||
self._presence_engine.update_presence()
|
# dekrementiert (line 2794). send() kann mehrfach pro Turn
|
||||||
|
# aufgerufen werden (Multi-Message, Split) — ein decrement hier
|
||||||
|
# würde den Agenten vorzeitig auf "online" setzen.
|
||||||
return SendResult(success=True, message_id=str(int(time.time() * 1000)))
|
return SendResult(success=True, message_id=str(int(time.time() * 1000)))
|
||||||
return SendResult(success=False, error="chat.postMessage failed")
|
return SendResult(success=False, error="chat.postMessage failed")
|
||||||
|
|
||||||
@@ -6237,10 +6243,9 @@ class RocketChatAdapter(BasePlatformAdapter):
|
|||||||
)
|
)
|
||||||
|
|
||||||
if last_msg_id:
|
if last_msg_id:
|
||||||
# ── V8.6 P1-4: PresenceEngine — active_tasks-- nach Split-Response ──
|
# ── V8.6 P1-4: PresenceEngine — KEIN decrement in _send_split! ──
|
||||||
if hasattr(self, '_presence_engine') and self._presence_engine is not None:
|
# Der Counter wird NUR im finally-Block von _process_incoming
|
||||||
self._presence_engine.decrement_active_tasks()
|
# dekrementiert (line 2794). _send_split ist ein Sub-Pfad von send().
|
||||||
self._presence_engine.update_presence()
|
|
||||||
return SendResult(success=True, message_id=last_msg_id)
|
return SendResult(success=True, message_id=last_msg_id)
|
||||||
return SendResult(success=False, error="All chunks failed")
|
return SendResult(success=False, error="All chunks failed")
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,13 @@ import urllib.error
|
|||||||
from typing import Optional, Dict
|
from typing import Optional, Dict
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
# Ensure presence_engine logs are visible in journalctl by adding a stderr handler
|
||||||
|
if not logger.handlers:
|
||||||
|
_pe_handler = logging.StreamHandler()
|
||||||
|
_pe_handler.setLevel(logging.INFO)
|
||||||
|
_pe_handler.setFormatter(logging.Formatter("%(asctime)s %(levelname)s %(name)s: %(message)s"))
|
||||||
|
logger.addHandler(_pe_handler)
|
||||||
|
logger.propagate = False # Don't double-log to root
|
||||||
|
|
||||||
|
|
||||||
# ═══════════════════════════════════════════════════════════════════════════
|
# ═══════════════════════════════════════════════════════════════════════════
|
||||||
@@ -297,7 +304,7 @@ class PresenceEngine:
|
|||||||
"X-User-Id": self._rest.user_id,
|
"X-User-Id": self._rest.user_id,
|
||||||
},
|
},
|
||||||
data=data)
|
data=data)
|
||||||
logger.debug(
|
logger.info(
|
||||||
"[presence] Status set: status=%s, message=%s",
|
"[presence] Status set: status=%s, message=%s",
|
||||||
status, message[:50] if message else "",
|
status, message[:50] if message else "",
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user