From 977bfe22f986c3a7257dc9f054ac8d6e6a01e863 Mon Sep 17 00:00:00 2001 From: autodev-bot Date: Tue, 30 Jun 2026 15:16:52 +0800 Subject: [PATCH] fix(scheduler): surface live local-queue counts in /scheduler/allstatus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit handle_scheduler_allstatus only aggregated per-stream entries whose key starts with "scheduler:" — these only exist for the Redis-backed message queue. Under DEFAULT_USE_REDIS_QUEUE=false (Docker, no Redis) the TaskScheduleMonitor returns just the flat top-level totals (running, remaining, pending) without any per-stream entries, so the prefix filter collapsed the summary to zero regardless of actual queue depth or dispatcher in-flight count. Users observed scheduler "initialized but not processing tasks" because /product/scheduler/allstatus always reported all zeros even though the consumer thread was alive and dispatching MEM_READ tasks. Detect whether per-stream entries are present; if not and mem_scheduler.use_redis_queue is False, fall back to the flat totals so in_progress / waiting / pending reflect the live state of the local queue and dispatcher. Redis-queue aggregation is unchanged. Fixes #1395 --- src/memos/api/handlers/scheduler_handler.py | 46 +++++- tests/api/test_scheduler_handler_allstatus.py | 151 ++++++++++++++++++ 2 files changed, 190 insertions(+), 7 deletions(-) create mode 100644 tests/api/test_scheduler_handler_allstatus.py diff --git a/src/memos/api/handlers/scheduler_handler.py b/src/memos/api/handlers/scheduler_handler.py index e7b756a1f..61d0d0b99 100644 --- a/src/memos/api/handlers/scheduler_handler.py +++ b/src/memos/api/handlers/scheduler_handler.py @@ -146,18 +146,50 @@ def _aggregate_counts_from_redis( sched_failed = all_tasks_summary.failed sched_cancelled = all_tasks_summary.cancelled - # If queue monitor is available, prefer its live waiting/in_progress counts + # If queue monitor is available, prefer its live waiting/in_progress counts. + # + # Two queue backends produce different ``queue_status_data`` shapes: + # - Redis queue: ``{"running": .., "remaining": .., "pending": .., + # ":::