Skip to content

Protocol violations (rc=0 without complete/block) don't increment failure_limit counter #32747

Closed as not planned

Description

@sfurey-bit

Summary

When a worker process exits with rc=0 without calling kanban_complete or kanban_block, the dispatcher correctly emits a protocol_violation event, but does NOT increment the task's failure counter. This means failure_limit never triggers for this failure mode, and the card re-dispatches indefinitely.

Repro

  1. Set failure_limit: 2 in config.yaml
  2. Dispatch a card whose worker consistently exits rc=0 without calling complete/block
  3. Observe: dispatcher emits protocol_violation each cycle, failure counter stays at 0, card re-dispatched indefinitely

Observed

Card t_9250007f accumulated 69 dispatch cycles with failure_limit=2 configured. Never auto-blocked. Had to be manually blocked.

Expected

failure_limit should apply to ALL terminal outcomes — crash (non-zero rc), timeout, AND protocol violations (rc=0 without complete/block). Any of these should increment the failure counter.

Activity

  1. added
    type/bugSomething isn't working
    P3Low — cosmetic, nice to have
    comp/cronCron scheduler and job management
    on May 26, 2026
  2. alycda commented on May 27, 2026

    @alycda

    Confirming this reproduces with strong evidence on v0.14.0 (2026.5.16) — and the loss is worse than the original report suggests, because every cycle is an API call.

    Same bug shape, two independent runs

    Run A — May 18–26, 37 concurrent tasks (board "qe", auto-decomposed research cards). All 37 tasks accumulated 270–285 consecutive protocol_violation events each over ~8 days. None auto-blocked despite the dispatcher emitting gave_up on every cycle with failures=1, effective_limit=1. Diagnostics surfaced this as critical repeated_crashes (the → Check logs advice was accurate; the auto-block never fired). I eventually mass-blocked by hand to stop the loop.

    Sample event sequence (task t_6907c842, 4,243 events total):

    [run N]   spawned
    [run N]   protocol_violation {exit_code: 0}
    gave_up   {failures: 1, effective_limit: 1, error: '...protocol violation'}
    promoted                                      # <- re-promoted despite gave_up
    [run N+1] claimed
    [run N+1] spawned
    ...
    

    Run B — May 27, fresh DB, --max-retries 1 set on a single task. After resetting the kanban DB to investigate, I created one task (t_f76f2272) with --max-retries 1 --max-runtime 5m. It still cycled through crashed → gave_up → promoted → claimed 3+ times before I blocked it. --max-retries on the task does not cap the dispatch loop for this failure mode either, matching this bug.

    Suggested fix scope

    gave_up already knows the outcome (trigger_outcome: 'crashed'), so the same guard could apply: if gave_up fired for this run, do not promote. As written the promotion happens unconditionally after gave_up, which is what makes the counter-not-incrementing problem catastrophic — even without fixing the counter, honoring the gave_up terminal signal would break the loop.

    Cost

    Each cycle on these tasks took ~2–3 min and spent ~7–10k tokens of API budget per spawn. The 270x crash counts × 37 tasks × ~10k tokens is non-trivial spend on a strictly broken control loop. Worth prioritizing the fix; happy to test a patch.

  3. ga1205 commented on Jun 5, 2026

    @ga1205

    +1, and a variant worth folding into this issue: the same gap applies when the worker DOES call kanban_complete but the call is rejected.

    In our production case (v0.15.0, details in my comment on #35202) the worker finished its task and called kanban_complete, which failed with could not complete <id> (unknown id or already terminal) because the dispatcher's watchdog had already reclaimed the run as a dead pid. From the breaker's point of view this is identical to your rc=0-without-complete case: a terminal outcome that advances no counter. The task re-dispatched 10 consecutive times with failure_limit: 2 configured; board diagnostics counted consecutive_crashes=10 correctly the whole time.

    Your "Expected" section says it exactly: failure_limit should apply to ALL terminal outcomes. I'd add rejected completions to that list alongside crash, timeout, and clean-exit protocol violations.

    One more data point for triage: each phantom re-dispatch is a full LLM run. Ours burned a shared provider quota and then rolled onto a metered API key via fallback_providers. With your 69-cycle card and the 1,192-crash case in #35202, this failure family is anuncapped-spend bug, not P3/cosmetic.

  4. teknium1 commented on Jul 13, 2026

    @teknium1
    Collaborator

    This is implemented on current main. Automated hermes-sweeper review verified the exact rc=0-without-terminal-transition path.

    • hermes_cli/kanban_db.py:6632-6647 records a clean exit while still running as protocol_violation.
    • hermes_cli/kanban_db.py:6745-6755 invokes _record_task_failure(..., failure_limit=1) for that path, immediately blocking the task and emitting gave_up rather than allowing a redispatch loop.
    • tests/hermes_cli/test_kanban_core_functionality.py:4401-4455 covers the regression: rc=0 plus no kanban_complete/kanban_block produces protocol_violation and gave_up, with task status blocked.
    • The implementation landed in fdb9e0f6a65e77f795d32cd782520622a150301d (fix(kanban): auto-block workers that exit without completing) and is contained in v2026.5.7.

    The later discussion's rejected-completion/stale-reclaim scenario is a distinct lifecycle-race concern; this issue's reported protocol-violation failure-counter loop is already fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Low — cosmetic, nice to havecomp/cronCron scheduler and job managementsweeper:implemented-on-mainSweeper: behavior already present on current maintype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions