Skip to content

bug(kanban): failure_limit circuit breaker bypassed when worker crashes before first heartbeat #35202

Open

Description

@frankyh75

Summary

kanban.failure_limit does not auto-block tasks when the worker crashes before sending its first heartbeat. Affected cases include invalid skill names, import errors, and any startup exception. The task respawns indefinitely — every dispatch_interval_seconds — regardless of failure_limit value.

Reproduction

  1. Create a kanban task with a skill name that doesn't exist:
    hermes kanban create --board <board> --body "test" --skills nonexistent-skill
    
  2. Set kanban.failure_limit: 2 in config (or any value)
  3. Observe: task spawns, crashes with ValueError: Unknown skill(s), gets reclaimed and respawned every 60s without ever being auto-blocked

Root cause

The crash happens before the worker writes its first heartbeat or lock entry. detect_crashed_workers identifies the dead process, but the consecutive_failures counter stored against the task lock entry is never created (no lock = no counter). Each dispatch cycle therefore sees the task as having 0 failures and re-claims it, resetting the circuit breaker window.

Post-heartbeat crashes (worker dies mid-execution) correctly increment consecutive_failures because a lock entry exists.

Impact (real-world case)

Observed in production on hermes-agent 0.14.0:

  • Skill name typo (foundry-vtt-mcp-macos → foundry-vtt-macos) caused 1192 consecutive crashes over 48 hours
  • failure_limit: 2 never triggered
  • System load peaked at 17.26 on a 20-core M1 Ultra
  • Contributed to gateway crash loop → 1000+ Discord reconnect attempts → system reboot

Expected behaviour

After failure_limit consecutive pre-heartbeat crashes, the task should be auto-blocked with a diagnostic message explaining the startup failure (same as post-heartbeat auto-block behaviour).

Suggested fix

Track pre-heartbeat spawn failures in a separate counter on the task record itself (not on the transient lock entry), so the circuit breaker fires regardless of whether a heartbeat was ever sent.

Note: PR #33747 (preflight skill validation at dispatch time) addresses the skill-name case specifically and will prevent this for that class of errors. This issue covers the general mechanism — any startup crash bypasses the circuit breaker today.

Environment

  • hermes-agent 0.14.0 / 0.15.1
  • macOS 15 (M1 Ultra)
  • kanban.failure_limit: 2, kanban.dispatch_interval_seconds: 60

Activity

  1. added
    type/bugSomething isn't working
    P3Low — cosmetic, nice to have
    comp/cliCLI entry point, hermes_cli/, setup wizard
    on May 30, 2026
  2. ga1205 commented on Jun 5, 2026

    @ga1205

    I would not consider this a P3. It is much more severe. I'm having this issue in production now. I wanted to have a good summary for this note, so the following was organized with Claude's help. The issue is significant though as it affects a number of other reported bugs and can result in Codex being fully used up AND runaway costs with API keys. That is very serious. Here's what I'm seeing:

    I hit this in production last night, with a variant mechanism and a nastier issue than the original report above. Sharing because I think the impact class is mis-triaged as P3/cosmetic: this is a cost-control failure, not a cosmetic one.

    Environment

    • Hermes Agent v0.15.0 (2026.5.28), official Docker image (nousresearch/hermes-agent:latest), s6 container layout
    • Multi-container fleet, shared kanban boards (bind-mounted board dirs), kanban.dispatch_in_gateway: true
    • Worker = same-named profile (hermes profile create <name> --clone)
    • Primary provider: ChatGPT/Codex OAuth; fallback: Anthropic API key (where configured)

    What happened

    A dispatcher picked up a simple retrieval task. The worker completed the work successfully, but:

    1. kanban_complete was rejected with could not complete <id> (unknown id or already terminal). The dispatcher's watchdog had already declared the run dead (pid <n> not alive, consistently at ~28s into each run) and re-queued the task. This looks like Protocol violations (rc=0 without complete/block) don't increment failure_limit counter #32747 / fix(kanban): count stale-claim reclaims toward circuit breaker #35212 territory: the work finishes, the completion handshake loses the race, and the breaker counter never advances.
    2. The task respawned and re-ran 10 consecutive times, each run re-doing the full (LLM-driven) task. The board diagnostics correctly recorded consecutive_crashes=10 and posted a [critical] diagnostic, but with failure_limit at its default of 2 the task was never auto-blocked. The diagnostics counter and the circuit-breaker counter are evidently different state, and the breaker never fires on this path.

    hermes kanban runs <id> gives a clean repro record, 6 of the 10:

      5  crashed   mybot   28s  ✖ pid 2466 not alive
      6  crashed   mybot   28s  ✖ pid 2481 not alive
      7  crashed   mybot   28s  ✖ pid 2495 not alive
      8  crashed   mybot   28s  ✖ pid 2510 not alive
      9  crashed   mybot   28s  ✖ pid 2525 not alive
     10  crashed   mybot   28s  ✖ pid 2534 not alive
    

    (The ~28s constant interval on a named-profile worker may also relate to #36981.)

    Why this is worse than "cosmetic"

    Each phantom-crash respawn is a full paid LLM run. The cascade we ate:

    1. 10x re-runs burned through the shared ChatGPT/Codex subscription's usage window (HTTP 429: usage limit reached),
    2. after which the OAuth credential was invalidated fleet-wide (four containers sharing one account; refresh storm after the 429),
    3. agents with an Anthropic fallback_providers entry silently rolled onto the metered API key. The unbounded crash loop graduates from "burning quota" to "burning money" with no ceiling,
    4. agents without a fallback went dark entirely.

    The original report's 1,192-crashes-in-48h case shows the loop is unbounded in time; ours shows each loop iteration can be a full-cost model invocation routed to a paid API. An unbounded retry loop with paid-API fallback is effectively an uncapped spend bug. I'd argue for P1/P2.

    Suggested fix (supporting the OP's and as diagnosed by Claude)

    Track consecutive non-success attempts on the task record itself (the diagnostics system already counts them correctly; consecutive_crashes=10 was right there), and have the breaker read that, so it fires regardless of heartbeat/lock state and regardless of crash classification (pre-heartbeat, watchdog reclaim, rejected completion / protocol violation). That single change would close the gap in #35202, #32747, and #35212 together.

  3. GottZ commented on Jul 30, 2026

    @GottZ

    This was generated by AI during triage.

    Summary

    One PR, #35212, addresses #35202 by recording failures when stale host-local claims are reclaimed, targeting the pre-heartbeat crash path whose failure count otherwise remains at zero. Its current diff only partially covers the root cause because it uses the default failure limit and applies to every host-local stale reclaim rather than specifically confirmed dead-worker reclaims.

    Related pull requests

    Suggested consolidation

    Merge #35212 after revising it to distinguish confirmed dead-worker reclaims from live-PID heartbeat-stale reclaims, pass the configured failure_limit through the reclaim and related recorder paths, and test the configured-limit behavior. It is the only and best candidate for #35202, but the visible contributor keep_open review identifies concrete defects in the current diff, so merging it unchanged is not recommended; there are no duplicate PRs to close.

    Complex graph

    flowchart LR
        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
        I35202(["issue #35202 (open)"])
        P35212["PR #35212 (open)"]
        P35212 -->|best fix| I35202
        class I35202 open
        class I35202 target
        class P35212 open
        class P35212 best
        click I35202 "https://github.com/NousResearch/hermes-agent/issues/35202"
        click P35212 "https://github.com/NousResearch/hermes-agent/pull/35212"
    
    Loading

    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 1 pull request and 1 issue in this complex. Each diff was read against this issue; Assessment working set: 4 kB of PR diffs, 6 kB of issue/PR text, 9 kB of discussion (4 comments), 2 verify verdicts. verdicts reflect diff content, not PR titles. Part of an automated triage batch.

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/cliCLI entry point, hermes_cli/, setup wizardtype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions