fix(kanban): auto-block workers on terminal conversation-loop errors (t_8165e956) - #17
Conversation
When a kanban worker conversation loop ends with completed=False / partial=True (truncation give-up), exit rc=0 with no lifecycle write used to look like a bare protocol violation. The dispatcher requeued forever and burned 12+ runs (t_8165e956). Worker path (chat -q / -Q): - detect terminal loop results - auto-call block_task(kind=transient) with a terminal-loop-error reason - always exit KANBAN_TERMINAL_LOOP_EXIT_CODE (76), never clean rc=0 Dispatcher path: - classify exit 76 as terminal_loop_error (distinct from protocol_violation) - if the task is still running, auto-block with loop-error wording so BEL triage does not have to grep session logs Regression coverage in test_kanban_terminal_loop_error.py. Kanban: t_8165e956
Producer handoff — t_8165e956 (CEA)Exact head: Acceptance map
Files (this commit only)
Deployment / rollbackLibrary-only worker exit + crash detection. No schema/migration/prod deploy. Rollback = revert PR. Next owner: TRC ( Kanban: |
TRC exact-head technical review — PR #17Head reviewed: Entry gateStructurally present and verified independently (not taken on the producer's word):
Behavioral verification (independently re-run, not re-quoting the producer)
Design review
FindingsNone blocking. No critical/high findings. Verdict: PASSGATEWAY-VERDICT: TRC=PASS head=0de18aa3e558f4a0cb610e3b8ff5d403141729b0 — Tessa Cole · credentials: eng-technical-review (TRC) · agent: tessa-cole 🪙 Token usage (from Hermes state.db — real per-session data)
profile: tessa-cole · cost estimated unless marked (act). Recorded per the tokens-to-value deliverable. CPTC actual: compare these real tokens with the predicted Complexity Points on the technical-scope sub-issue. |
…rced_signal _classify_worker_exit must still return terminal_loop_error for exit 76 (#17) before shell 128+N forced_signal. Restores CI slice failures from tests/hermes_cli/test_kanban_terminal_loop_error.py without losing the SIGTERM/rc=0 protocol_violation distinction.
…col_violation (#22) * fix(kanban): stop miscounting forced kills and init failures as protocol_violation Root cause of the t_fe90ab52 50× ~60s crash loop: 1. Non-quiet single-query (`chat -q`) init/run failures printed Goodbye and exited rc=0. Dispatcher reaped that as clean-exit protocol_violation after one dispatch_interval_seconds tick (~60s on default gateway). 2. Kanban SIGTERM handler called os._exit(0), collapsing forced kills. Fix (rebased onto current fork/main; preserves terminal-loop exit helper): - Human -q path: sys.exit(1) when chat() returns None - Kanban SIGTERM: os._exit(128+signum) → 143 - Reaper: forced_signal kind is not protocol_violation Kanban: t_5229e0ea / Linear HEL-3145 * fix(kanban): preserve terminal_loop_error classification alongside forced_signal _classify_worker_exit must still return terminal_loop_error for exit 76 (#17) before shell 128+N forced_signal. Restores CI slice failures from tests/hermes_cli/test_kanban_terminal_loop_error.py without losing the SIGTERM/rc=0 protocol_violation distinction. --------- Co-authored-by: SSC-ENG <225143396+SSC-ENG@users.noreply.github.com>
Summary
Fixes the kanban worker burn loop where conversation-loop truncation give-up (
completed=False/partial=True, e.g. "Response remained truncated after 4 continuation attempts") exitedrc=0with no lifecycle write. The dispatcher recorded a bare protocol violation, requeued, and burned 12+ ~15-min runs.Worker path (
chat -qand-Q)is_terminal_conversation_loop_resultblock_task(kind=transient)with aterminal loop error:reason + run metadataKANBAN_TERMINAL_LOOP_EXIT_CODE(76) — never cleanrc=0Dispatcher path
terminal_loop_error(distinct fromprotocol_violation)running, force-trip the breaker on first occurrence with loop-error wording (does not use the protocol-violation retry budget — truncating again is deterministic waste)Tests
tests/hermes_cli/test_kanban_terminal_loop_error.py— 6 cases covering shape detection, worker auto-block, quiet main exit 76, and dispatcher classification.Kanban:
t_8165e956Test plan
python -m pytest tests/hermes_cli/test_kanban_terminal_loop_error.py -q(6 passed)tessa-cole)Deployment impact
Library/behavior change in hermes-agent kanban worker exit + crash detection only. No schema migration, no prod deploy, no DB apply.
Rollback
Revert this PR / redeploy prior hermes-agent revision. Cards already auto-blocked remain blocked until human unblock (correct).