Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix(observer): ignore drained queue errors in health (#4327)

Zayn Jarvis193d137ba837
diff --git a/openviking/storage/observers/queue_observer.py b/openviking/storage/observers/queue_observer.py
index 9dfc74cfe..8707a7773 100644
--- a/openviking/storage/observers/queue_observer.py
+++ b/openviking/storage/observers/queue_observer.py
@@ -122,4 +122,15 @@ class QueueObserver(BaseObserver):
return not self.has_errors()
def has_errors(self) -> bool:
- return self._queue_manager.has_errors()
+ return run_async(self.has_active_errors_async())
+
+ async def has_active_errors_async(self) -> bool:
+ statuses = await self._queue_manager.check_status()
+ return self._has_active_errors(statuses)
+
+ @staticmethod
+ def _has_active_errors(statuses: Dict[str, QueueStatus]) -> bool:
+ return any(
+ status.error_count > 0 and not status.is_complete
+ for status in statuses.values()
+ )
diff --git a/tests/storage/test_queue_observer.py b/tests/storage/test_queue_observer.py
new file mode 100644
index 000000000..c928bbe1b
--- /dev/null
+++ b/tests/storage/test_queue_observer.py
@@ -0,0 +1,79 @@
+# Copyright (c) 2026 Beijing Volcano Engine Technology Co., Ltd.
+# SPDX-License-Identifier: AGPL-3.0
+"""Tests for QueueObserver health semantics."""
+
+from openviking.storage.observers.queue_observer import QueueObserver
+from openviking.storage.queuefs.named_queue import QueueStatus
+
+
+class _FakeQueueManager:
+ SEMANTIC = "Semantic"
+
+ def __init__(self, statuses: dict[str, QueueStatus]):
+ self._statuses = statuses
+ self._queues = {}
+
+ async def check_status(self) -> dict[str, QueueStatus]:
+ return self._statuses
+
+
+def test_historical_queue_errors_do_not_make_drained_queue_unhealthy() -> None:
+ observer = QueueObserver(
+ _FakeQueueManager(
+ {
+ "Semantic": QueueStatus(
+ pending=0,
+ in_progress=0,
+ processed=69,
+ requeue_count=1,
+ error_count=1,
+ )
+ }
+ )
+ )
+
+ assert observer.has_errors() is False
+ assert observer.is_healthy() is True
+
+ table = observer.get_status_table()
+ assert "Semantic" in table
+ assert "Warnings:" not in table
+
+
+def test_queue_errors_make_pending_queue_unhealthy() -> None:
+ observer = QueueObserver(
+ _FakeQueueManager(
+ {
+ "Semantic": QueueStatus(
+ pending=1,
+ in_progress=0,
+ processed=69,
+ error_count=1,
+ )
+ }
+ )
+ )
+
+ assert observer.has_errors() is True
+ assert observer.is_healthy() is False
+
+ table = observer.get_status_table()
+ assert "Warnings:" not in table
+
+
+def test_queue_errors_make_in_progress_queue_unhealthy() -> None:
+ observer = QueueObserver(
+ _FakeQueueManager(
+ {
+ "Semantic": QueueStatus(
+ pending=0,
+ in_progress=1,
+ processed=69,
+ error_count=1,
+ )
+ }
+ )
+ )
+
+ assert observer.has_errors() is True
+ assert observer.is_healthy() is False