Repository navigation
Description
Bug Description
Hermes has two dispatcher paths that both act on the kanban DB but share no state:
- Gateway's embedded
_kanban_dispatcher_watcher— runsdispatch_once()every 60s inside the gateway process, incrementsbad_tickswhen it spawns 0 workers. - Hook's per-profile-dispatcher — runs as a separate OS hook every 60s, does the actual spawning when
max_spawn > 0.
When max_spawn=2 and the hook fills both concurrency slots, dispatch_once() inside the gateway returns spawned=0 — not because of a stall, but because all slots are occupied. The embedded watcher sees spawned=0 and increments bad_ticks, eventually logging:
kanban dispatcher stuck: 3 tasks ready, 0 workers spawned (bad_ticks=3)
This is a false alarm. Tasks are processing normally; the concurrency cap is simply full.
Steps to Reproduce
- Set
max_spawn=2inlocal-admin/config.yaml - Have ≥2 tasks running (hook dispatcher fills both concurrency slots)
- Have ≥1 additional task in
readystate - Wait 3+ watcher ticks (3+ minutes)
- Gateway logs:
kanban dispatcher stuck: N tasks ready, 0 workers spawned - All tasks are processing normally — alarm is false
Expected Behavior
No "stuck" alarm fires when the concurrency cap is full and tasks are actively running. The watcher distinguishes between "cap is full" (healthy throttling) and "slots available but nothing spawned" (genuine stall).
Actual Behavior
Gateway repeatedly logs kanban dispatcher stuck: N tasks ready, 0 workers spawned (bad_ticks=N) every 3 ticks (~3 minutes) during normal operation when max_spawn=2 and both slots are occupied by hook-spawned workers. False alarm — the board is healthy.
Affected Component
Gateway (Telegram/Discord/Slack/WhatsApp)
Messaging Platform (if gateway-related)
No response
Debug Report
gateway: running (s0 (container supervisor), pid 2050)
platforms: telegram
cron_jobs: 8 active / 13 total
skills: 48
config_overrides:
agent.max_turns: 150
agent.gateway_timeout: 3600
Note: gateway deployment in Docker container; hermes debug share --local used instead of upload.Operating System
macOS host + Docker Desktop (gRPC-FUSE/virtiofs); container: Linux 6.12.76-linuxkit aarch64
Python Version
3.13.5
Hermes Version
0.16.0 (2026.6.5) [a118b94]
Additional Logs / Traceback (optional)
Repeated in gateway log every ~60s when max_spawn=2 and both slots occupied:
kanban dispatcher stuck: 3 tasks ready, 0 workers spawned (bad_ticks=3)
kanban dispatcher stuck: 3 tasks ready, 0 workers spawned (bad_ticks=4)
kanban dispatcher stuck: 3 tasks ready, 0 workers spawned (bad_ticks=5)
Same period — three tasks in kanban DB:
task-abc: status=running (hook dispatcher, slot 1)
task-def: status=running (hook dispatcher, slot 2)
task-ghi: status=ready (waiting for a free slot)
All tasks completed normally; alarm was entirely spurious.Root Cause Analysis (optional)
_kanban_dispatcher_watcher in gateway/kanban_watchers.py (~line 1034 in 0.15.1 / 0.16.0) increments bad_ticks when ready_pending and not any_spawned.
The problem: any_capped is only set when dispatch_once() itself hits skipped_per_profile_capped — it is NOT set when the hook's per-profile-dispatcher has already filled the global max_spawn cap before the embedded watcher runs. So when max_spawn=2 and the hook holds both slots, dispatch_once() returns spawned=0 without setting skipped_per_profile_capped, and the watcher increments bad_ticks on every tick.
The fix: before incrementing bad_ticks, query the kanban DB for the total count of status='running' tasks across all boards. If running >= max_spawn, the cap is full — set bad_ticks = 0 instead of incrementing. Only a genuine stall (slots available, nothing spawned) should increment.
Proposed Fix (optional)
Patch: fix_kanban_watchers.patch — 54 lines, 1 hunk, applies with patch -p0
--- a/gateway/kanban_watchers.py
+++ b/gateway/kanban_watchers.py
@@ -1034,9 +1034,49 @@
len(res.auto_blocked) if hasattr(res.auto_blocked, "__len__") else 0,
)
# Health telemetry (aggregate across boards)
+ # Suppress false-alarm "stuck" warnings when tasks are blocked by
+ # per-profile or global max_spawn concurrency caps — that is normal
+ # throttled behaviour driven by the hook dispatcher, not a stall.
+ any_capped = any(
+ res is not None
+ and bool(getattr(res, "skipped_per_profile_capped", None))
+ for _, res in (results or [])
+ )
ready_pending = await asyncio.to_thread(_ready_nonempty)
- if ready_pending and not any_spawned:
- bad_ticks += 1
+ if ready_pending and not any_spawned and not any_capped:
+ # Also suppress when the global max_spawn cap is already
+ # exhausted by hook-spawned workers (dispatch_once breaks
+ # early before touching skipped_per_profile_capped).
+ def _get_running_count():
+ try:
+ boards_ = _kb.list_boards(include_archived=False)
+ except Exception:
+ boards_ = [_kb.read_board_metadata(_kb.DEFAULT_BOARD)]
+ total = 0
+ for b_ in boards_:
+ slug_ = b_.get("slug") or _kb.DEFAULT_BOARD
+ conn_ = None
+ try:
+ conn_ = _kb.connect(board=slug_)
+ row_ = conn_.execute(
+ "SELECT COUNT(*) FROM tasks WHERE status='running'"
+ ).fetchone()
+ total += row_[0] if row_ else 0
+ except Exception:
+ pass
+ finally:
+ if conn_:
+ try:
+ conn_.close()
+ except Exception:
+ pass
+ return total
+ running = await asyncio.to_thread(_get_running_count)
+ at_global_cap = max_spawn is not None and running >= max_spawn
+ if not at_global_cap:
+ bad_ticks += 1
+ else:
+ bad_ticks = 0
else:
bad_ticks = 0
if bad_ticks >= HEALTH_WINDOW:Apply with: patch -p0 < fix_kanban_watchers.patch
Are you willing to submit a PR for this?
- I'd like to fix this myself and submit a PR
Activity
hermesy-theshwal commentedon Jul 10, 2026
Confirmed reproduction + manual workaround applied 2026-07-10.
Symptoms (VisiPDP, ~1043 tests queued):
hermes kanban dispatch --max Nreturns 0/0/0/0/0/0/0 despite 4 ready + 4 free WIP slotskanban dispatcher stuck: ready queue non-empty for N consecutive ticks but 0 workers spawned(reached 431+ ticks)Root cause (not just false stuck warning):
claim_lock,claim_expires,worker_pidnot NULLed → scheduler ignores cardskanban_completeflowManual workaround that worked (cf. #22926 suggestion):
Then
hermes kanban dispatch --max 5spawns 1 worker per cycle (~3 min/card).Confirmation that #46800 is just false-positive log: spawn DOES happen, but watcher thinks it doesn't. The real fix is #22926 (claim cleanup).
Thanks for #22926 + #46892 — VisiPDP unblocked. Documented in incident 2026-07-10.
Wild-Eep commentedon Jul 10, 2026
I think this is mixing up two different bugs that just happen to log the same line.
Our repro for #46800 has no crashed workers at all. max_spawn=2, the hook’s own dispatcher fills both slots with tasks that are actively and healthily running, and a third task sits in ready. The gateway’s embedded watcher calls dispatch_once(), which correctly returns spawned=0 because there’s nothing left for it to spawn (the hook already did it). But any_capped only gets set from that call’s own skipped_per_profile_capped flag, so it has no idea the hook filled the cap in a different process. bad_ticks climbs even though the board is completely fine. No crashes, no stale claims, nothing to clean up. It’s a logging bug, full stop.
What you hit is different. Workers with real PIDs spawn and then die silently (OOM/timeout), and claim_lock/claim_expires/worker_pid never get cleared. That’s #22926: the dispatcher can’t tell a dead worker’s leftover claim from a live one, so the card never gets reassigned. The fix you applied (nulling those columns) is #22926’s fix, not #46800’s. Same symptom, totally different cause.
One thing your report does surface though: our fix (checking running >= max_spawn via a plain status=‘running’ count) would get fooled by your exact scenario too, since a dead worker’s stale row still counts as “running.” Might be worth having #22926’s cleanup also filter on claim_expires before either of these two fixes counts a row as real.
But that’s a reason to land both patches, not a reason #46800 isn’t a real bug.
hermesy-theshwal commentedon Jul 10, 2026
Thanks @Wild-Eep — you're right, my report conflated the two bugs. Correcting on the record:
The
UPDATE tasks SET claim_lock=NULL...is #22926's fix, not #46800's.One useful tie-in for whoever lands both: after my manual #22926 cleanup, #46800's "stuck" log also stopped — fresh workers spawned, no stranded cards, no false-positive. So #22926 cleanup is effectively a prerequisite for #46800's watcher fix to count "running" rows accurately (without it, stale claims would still pollute the count, as you noted). Folding the
claim_expires < nowfilter into the running-row check seems like the right shape.Will post the focused repro to #22926 separately.
GottZ commentedon Jul 30, 2026
Summary
Twelve PRs were triaged in this complex, but only #46892 and #65581 modify the false-stuck health predicate reported in #46800. #46892 probes externally occupied capacity but aggregates incompatible board-local counts, while #65581 introduces explicit deferral results and board-local gateway accounting, though its shown global-cap flag covers max_in_progress rather than every external max_spawn-cap path.
Related pull requests
unrelated— (+273/-62) — unrelated: Adds a per-profile dispatcher singleton lock, preventing concurrent watcher processes rather than distinguishing a healthy full concurrency cap from a stall. Closed but relevant as the earlier [Bug]: kanban dispatcher: gateway embeds dispatcher without singleton guard — two gateway instances cause claim-reclaim churn #41448 implementation superseded by the machine-global lock merged through fix(kanban): machine-global singleton lock for the embedded dispatcher (#41448) #49068.unrelated— (+106/-0) — unrelated: Implements the machine-global singleton dispatcher lock for [Bug]: kanban dispatcher: gateway embeds dispatcher without singleton guard — two gateway instances cause claim-reclaim churn #41448; it does not change bad_ticks or cap-full health classification. Closed but relevant because its reviewed implementation was cherry-picked and merged through fix(kanban): machine-global singleton lock for the embedded dispatcher (#41448) #49068.partial— (+256/-1) — partial fix: Directly suppresses fix: _kanban_dispatcher_watcher fires false "stuck" alert when hook fills concurrency cap #46800 warnings by counting running tasks when no worker spawns, but compares aggregate running counts across boards with min(caps), so one board can mask a real stall on another and the daemon path remains unchanged. Despite the keep_open review on fix(gateway): avoid false kanban stuck alerts at concurrency cap #46892, it should not remain the consolidation target because that review itself identifies these diff-level defects and fix(kanban): avoid false dispatcher stuck warnings #65581 now provides board-local accounting.unrelated— (+107/-0) — unrelated: Merged reference implementation of the machine-global singleton lock from fix(kanban): machine-global singleton lock for the embedded dispatcher (#41448) #44919 for [Bug]: kanban dispatcher: gateway embeds dispatcher without singleton guard — two gateway instances cause claim-reclaim churn #41448. It prevents duplicate dispatchers but does not distinguish intentional cap throttling from a genuinely stuck dispatcher.unrelated— (+90/-3) — unrelated: Promotes auto-decompose failures to rate-limited warnings, addressing [Bug]: Auto-decompose failures log at DEBUG — invisible when gateway runs at INFO #49859 rather than the false stuck warning in fix: _kanban_dispatcher_watcher fires false "stuck" alert when hook fills concurrency cap #46800. Despite its keep_open review and subsequently added logging tests, its diff does not alter dispatcher capacity health decisions.unrelated— (+170/-50) — unrelated: Installs a profile secret scope around auto-decomposition under multiplexing, fixing an UnscopedSecretError path rather than cap-full stuck telemetry. The keep_open review validates that separate bug but supplies no diff-level connection to fix: _kanban_dispatcher_watcher fires false "stuck" alert when hook fills concurrency cap #46800's bad_ticks cause.unrelated— (+98/-3) — unrelated: Coerces raw max_spawn config values to integers, addressing a quoted-YAML TypeError associated with Kanban dispatcher ignores max_in_progress_per_profile, spawns all tasks concurrently #59499, not healthy external workers filling the cap. Despite the keep_open review, its synthetic test and acceptance of non-positive values were also explicitly flagged, and the diff does not repair fix: _kanban_dispatcher_watcher fires false "stuck" alert when hook fills concurrency cap #46800's health predicate.unrelated— (+80/-9) — unrelated: Broadens dispatcher tick-summary logging to crash, timeout, reclaim, auto-block, and stale activity, but leaves the stuck-warning predicate unchanged. Despite the keep_open review and the later stale-only test, this remains an observability change for separate dispatcher outcomes.unrelated— (+48/-7) — unrelated: Makes gave_up notifications cause-neutral or uses the supplied event error; it does not touch dispatcher spawning, caps, or bad_ticks. Its keep_open review validates this separate notifier-formatting fix, not a fix for fix: _kanban_dispatcher_watcher fires false "stuck" alert when hook fills concurrency cap #46800.unrelated— (+392/-32) — unrelated: Prevents stale watcher snapshots from recreating archived boards by adding existing-only database opens, including auto-decomposition paths. Despite the keep_open review and reported remediation, the diff addresses board resurrection rather than false cap-full warnings.best fix— (+485/-35) — best partial fix: Adds explicit global/per-profile/lock/respawn deferral signals and applies board-local health accounting in both gateway and daemon paths, so a deferred board cannot mask a stuck board. The keep_open review on fix(kanban): avoid false dispatcher stuck warnings #65581 objected to cross-board any(...) aggregation; the shown revised diff directly addresses that objection with ready_boards - deferred_slugs - spawned_slugs and a multi-board regression, but the target's external max_spawn-full case still needs an explicit board-local deferral signal because skipped_global_capped is shown only for max_in_progress.unrelated— (+80/-8) — unrelated: Validates max_spawn as a positive integer and closes the parent worker-log handle after successful Popen, preventing config TypeErrors and handle leaks rather than classifying healthy cap saturation. Despite its keep_open review, which requests finally-based cleanup for non-FileNotFoundError spawn failures, neither change resolves fix: _kanban_dispatcher_watcher fires false "stuck" alert when hook fills concurrency cap #46800's specific health predicate.Duplicates
#41679, #44919, and merged #49068 are substantially the same #41448 singleton-lock change, with #49068 carrying the machine-global implementation from #44919. #46892 and #65581 overlap on false-stuck suppression, but #65581 has the stronger board-local design; #59588 and the max_spawn-validation portion of #65644 substantially overlap on raw max_spawn coercion.
Suggested consolidation
Merge #65581 as the consolidation base for #46800 after retaining its revised board-local gateway/daemon accounting and adding or verifying an explicit board-local deferral for the reported external max_spawn-full path. This recommendation explicitly departs from the earlier keep_open review because its blocking cross-board aggregation finding is addressed in the shown revised diff and multi-board regression; #46892 can then be closed as a superseded partial duplicate because its aggregate count can suppress real per-board stalls. Keep the unrelated fixes outside this consolidation, and treat merged #49068 only as the reference implementation for the separate singleton-dispatcher issue.
Complex graph
flowchart TD classDef open fill:#dbeafe,stroke:#1d4ed8,color:#1e3a8a classDef merged fill:#dcfce7,stroke:#15803d,color:#14532d classDef closed fill:#e5e7eb,stroke:#6b7280,color:#1f2937 classDef unverified fill:#f3f4f6,stroke:#9ca3af,color:#374151 classDef best stroke-width:3px,stroke:#b45309 classDef target stroke-width:3px,stroke:#4338ca I41448(["issue #41448 (closed)"]) I46800(["issue #46800 (open)"]) I49859(["issue #49859 (open)"]) P49861["PR #49861 (open)"] subgraph Dup41679 ["PRs duplicating each other"] P41679["PR #41679 (closed)"] P44919["PR #44919 (closed)"] P49068["PR #49068 (merged)"] end subgraph Dup46892 ["PRs duplicating each other"] P46892["PR #46892 (open)"] P65581["PR #65581 (open)"] end subgraph Dup59588 ["PRs duplicating each other"] P59588["PR #59588 (open)"] P65644["PR #65644 (open)"] end MoreI(["+1 more issues not shown"]) P46892 -.->|partial| I46800 P65581 -->|best fix| I46800 P41679 -.->|partial| I41448 P44919 -->|fixes| I41448 P49068 -->|best fix| I41448 P49861 -->|best fix| I49859 class I41448 closed class I46800 open class I49859 open class I46800 target class P41679 closed class P44919 closed class P46892 open class P49068 merged class P49861 open class P59588 open class P65581 open class P65644 open class P49068 best class P49861 best class P65581 best class MoreI closed click I41448 "https://github.com/NousResearch/hermes-agent/issues/41448" click I46800 "https://github.com/NousResearch/hermes-agent/issues/46800" click I49859 "https://github.com/NousResearch/hermes-agent/issues/49859" click P41679 "https://github.com/NousResearch/hermes-agent/pull/41679" click P44919 "https://github.com/NousResearch/hermes-agent/pull/44919" click P46892 "https://github.com/NousResearch/hermes-agent/pull/46892" click P49068 "https://github.com/NousResearch/hermes-agent/pull/49068" click P49861 "https://github.com/NousResearch/hermes-agent/pull/49861" click P59588 "https://github.com/NousResearch/hermes-agent/pull/59588" click P65581 "https://github.com/NousResearch/hermes-agent/pull/65581" click P65644 "https://github.com/NousResearch/hermes-agent/pull/65644"Graph: solid arrow = fixes / best fix, dashed arrow = partial or unverified (see edge label); boxed group = PRs duplicating each other; amber border = best fix; indigo border = target; gray node = closed (state tag in the node label).
Cross-PR triage: Reviewed 12 pull requests and 4 issues in this complex. Each diff was read against this issue; Assessment working set: 134 kB of PR diffs, 44 kB of issue/PR text, 33 kB of discussion (34 comments), 9 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.
GottZ commentedon Aug 3, 2026
Delta since our previous triage comment
Since the previous triage comment, @bwoliveira supplied production evidence confirming #57837's separate multiplex auto-decomposition failure and validating the proposed profile-secret-scope fix with a stale card decomposed after deployment. This strengthens #57837 on its own merits but does not connect its diff to #46800's false stuck-warning predicate.
Changed pull requests
unrelated— (+170/-50) — unrelated: New field evidence from @bwoliveira confirms that installing the profile secret scope restores auto-decomposition under multiplexing; despite the keep_open review on fix(kanban): run auto-decompose tick under the profile secret scope #57837, this remains a separate credential-scope fix and does not alter cap-full health classification or bad_ticks.Suggested consolidation
The consolidation recommendation is unchanged: #65581 remains the best existing partial fix, but no PR in this complex is currently merge-lane eligible.
Complex graph unchanged since our previous triage comment.
Cross-PR triage: Reviewed 12 pull requests and 4 issues in this complex. Each diff was read against this issue; Assessment working set: 134 kB of PR diffs, 44 kB of issue/PR text, 28 kB of discussion (29 comments), 10 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.
rodrigogs commentedon Sep 6, 2026
Opened #104144 for this. It records the cap outcome where it is decided -
_tick_spawn_budgetnow setscapacity_deferredat both themax_spawnandmax_in_progressearly returns - and the watcher treats a board whose only reason forspawned=0is a full cap as healthy instead of stuck. The hook-filled scenario in this report is covered becausecount_running_tasksalready counts hook-spawned rows; the fix is that the watcher finally reads that result. The same classification is applied per board, so a capped board cannot hide a stalled sibling, and the--daemonpath uses the same decision. No DB re-query inside the watcher.fix(kanban): classify idle dispatch ticks so a full board is not stuck