Repository navigation
fix(chat): let a resolved Stop veto the lost-session reconnect replay - #16548
Conversation
The session-not-found arm queued its one reconnect replay unless _should_suppress_requeue(slot) was true, which only sees a Stop still in flight. A Stop that already resolved back to idle moved only the Stop counters, and the replay snapshots are taken after it, so the drain-side veto read 'not stopped' and the cancelled prompt ran again. Pair the gate with _stop_pressed(), as every sibling requeue gate does. Fixes #16547
Design Review (Opus 5.5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS Three sibling recovery arms in Watch
Suggestions
[DESIGN-REVIEWED] c692a07 Description read[DESCRIPTION-READ] 44958ebc07413ddcee5f08d9d0d33c61acc63ca512be74c17b83ef8d963c6097 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The fix covers one of four replay arms. The description says "every sibling requeue gate" already pairs Not justified as shipped
What this change shipsInventory (2 items) — 1 justifiedIntent: a prompt the user stopped must not run again when the lost-session reconnect fires. FIX.
[FIRST-PRINCIPLES-REVIEWED] c692a07 Description read[DESCRIPTION-READ] 2851067f50aae59939557f186c714454eb884637a031738cd5400b9b90c5a5cb That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
kirodotdev#16548 paired _stop_pressed() with _should_suppress_requeue() on _run_chat's lost-session arm. Two sibling arms of the same except chain still gated their replay on the suppress check alone, which sees only a Stop still in flight: the AcpProcessDied requeue and the busy / pipe-death AcpError requeue. A Stop that pressed and resolved back to idle before the error reached the handler moved only the Stop counters, so the stopped prompt was queued for verbatim replay on a fresh runtime. _queue_recovery takes no Stop snapshot of its own, so the gate is the only place that can see it. The transient-5xx arm, named alongside these by the kirodotdev#16548 reviews, already re-reads _stop_pressed() after its backoff and drops the replay, so it is left as is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kirodotdev#16548 paired _stop_pressed() with _should_suppress_requeue() on _run_chat's lost-session arm. Two sibling arms of the same except chain still gated their replay on the suppress check alone, which sees only a Stop still in flight: the AcpProcessDied requeue and the busy / pipe-death AcpError requeue. A Stop that pressed and resolved back to idle before the error reached the handler moved only the Stop counters, so the stopped prompt was queued for verbatim replay on a fresh runtime. _queue_recovery takes no Stop snapshot of its own, so the gate is the only place that can see it. The transient-5xx arm, named alongside these by the kirodotdev#16548 reviews, already re-reads _stop_pressed() after its backoff and drops the replay, so it is left as is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
kirodotdev#16548 paired _stop_pressed() with _should_suppress_requeue() on _run_chat's lost-session arm. Two sibling arms of the same except chain still gated their replay on the suppress check alone, which sees only a Stop still in flight: the AcpProcessDied requeue and the busy / pipe-death AcpError requeue. A Stop that pressed and resolved back to idle before the error reached the handler moved only the Stop counters, so the stopped prompt was queued for verbatim replay on a fresh runtime. _queue_recovery takes no Stop snapshot of its own, so the gate is the only place that can see it. The transient-5xx arm, named alongside these by the kirodotdev#16548 reviews, already re-reads _stop_pressed() after its backoff and drops the replay, so it is left as is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…e arms Follow-up to merged #16548, which gave only the lost-session arm the `_stop_pressed()` read. The runtime-death arm, the prompt-busy / pipe-death arm, and the post-busy-exhaustion requeue helper still gate on `_should_suppress_requeue(slot)` alone, so a Stop that pressed and resolved back to idle before the error reached the handler (invisible to the suppress check, and `_queue_recovery` takes no Stop snapshot of its own) still queues the stopped prompt for replay on a fresh runtime. Pair each remaining arm's gate with `_stop_pressed()`, the same pairing #16548 used, and thread `_stop_pressed` into `_requeue_after_prompt_busy` so the recovery helper can see it too. Adds a parametrised test covering all four arms with a positive control (no Stop replays once) and the stopped case (resolved Stop queues nothing). Replaces #16767 by @leonlaiyc. Co-authored-by: Leon <276034861+leonlaiyc@users.noreply.github.com>
…e arms Follow-up to merged #16548, which gave only the lost-session arm the `_stop_pressed()` read. The runtime-death arm, the prompt-busy / pipe-death arm, and the post-busy-exhaustion requeue helper still gate on `_should_suppress_requeue(slot)` alone, so a Stop that pressed and resolved back to idle before the error reached the handler (invisible to the suppress check, and `_queue_recovery` takes no Stop snapshot of its own) still queues the stopped prompt for replay on a fresh runtime. Pair each remaining arm's gate with `_stop_pressed()`, the same pairing #16548 used, and thread `_stop_pressed` into `_requeue_after_prompt_busy` so the recovery helper can see it too. Adds a parametrised test covering all four arms with a positive control (no Stop replays once) and the stopped case (resolved Stop queues nothing). Replaces #16767 by @leonlaiyc. Co-authored-by: Leon <276034861+leonlaiyc@users.noreply.github.com>
…e arms Follow-up to merged #16548, which gave only the lost-session arm the `_stop_pressed()` read. The runtime-death arm, the prompt-busy / pipe-death arm, and the post-busy-exhaustion requeue helper still gate on `_should_suppress_requeue(slot)` alone, so a Stop that pressed and resolved back to idle before the error reached the handler (invisible to the suppress check, and `_queue_recovery` takes no Stop snapshot of its own) still queues the stopped prompt for replay on a fresh runtime. Pair each remaining arm's gate with `_stop_pressed()`, the same pairing #16548 used, and thread `_stop_pressed` into `_requeue_after_prompt_busy` so the recovery helper can see it too. Adds a parametrised test covering all four arms with a positive control (no Stop replays once) and the stopped case (resolved Stop queues nothing). Replaces #16767 by @leonlaiyc. Co-authored-by: Leon <276034861+leonlaiyc@users.noreply.github.com>
…e arms (#18401) * fix(chat): let a resolved Stop veto the runtime-death and busy requeue arms Follow-up to merged #16548, which gave only the lost-session arm the `_stop_pressed()` read. The runtime-death arm, the prompt-busy / pipe-death arm, and the post-busy-exhaustion requeue helper still gate on `_should_suppress_requeue(slot)` alone, so a Stop that pressed and resolved back to idle before the error reached the handler (invisible to the suppress check, and `_queue_recovery` takes no Stop snapshot of its own) still queues the stopped prompt for replay on a fresh runtime. Pair each remaining arm's gate with `_stop_pressed()`, the same pairing #16548 used, and thread `_stop_pressed` into `_requeue_after_prompt_busy` so the recovery helper can see it too. Adds a parametrised test covering all four arms with a positive control (no Stop replays once) and the stopped case (resolved Stop queues nothing). Replaces #16767 by @leonlaiyc. Co-authored-by: Leon <276034861+leonlaiyc@users.noreply.github.com> * fix(chat): let a resolved Stop veto the image-history and poisoned-reset replays Self-review follow-up. The image-history recovery and the poisoned-conversation reset arm still gated their replay on _should_suppress_requeue(slot) alone, and each takes its Stop snapshot (_image_stop_gen, _stop_gen_before_canary) after a resolved Stop already moved the counter, so the stopped prompt was replayed on a fresh session. Pair both gates with _stop_pressed() (the image arm's owed-completion half is unchanged). Also give the transient-5xx arm's first gate its own resolved-Stop branch, so a resolved Stop no longer flashes a "retrying" card the post-backoff re-read withdraws. That branch ends the turn with no requeue, so it resets the same four per-turn budgets the post-backoff drop arm resets (_transient_5xx_retries, _infra_retries, _fallback_candidate_idx, _fallback_walked); otherwise the attempt it just counted shortens the next turn's 5xx ladder. Tests: image-history, transient-5xx and poisoned-reset cases in test/test_chat_requeue_resolved_stop.py; each stopped case fails on base. A budget case checks a resolved Stop on a transient 5xx leaves all four fields at zero for the next turn. The file patches the runner's _recovery_delay seam instead of a process-wide asyncio.sleep (Determinism contract / flake-pattern ratchet). --------- Co-authored-by: cixuuz <26782336+cixuuz@users.noreply.github.com> Co-authored-by: Leon <276034861+leonlaiyc@users.noreply.github.com>
Problem / Motivation
Goal: Pressing Stop on a chat whose backend lost its session never lets the stopped prompt run again.
The lost-session reconnect added in #16221 queues one replay of the turn's prompt unless
_should_suppress_requeue(slot)is true. That check only sees a Stop that is still in flight. A Stop that the user pressed and that already resolved back to idle (a backend holding no session answers Stop as idle) leaves_stoppingfalse and only moves the Stop counters. The replay is queued, its Stop snapshots are taken after that Stop, so the drain-side veto also reads "not stopped", and the prompt the user cancelled runs again.Why it matters
The replayed prompt is one the user explicitly stopped. If it was destructive ("delete the old branches"), Stop did not prevent it.
Not a goal
The other turn surfaces (#16225 / #16428) and the other recovery arms are untouched here.
What changed (motivation → approach → change)
src/kiro_crew/dashboard/chat_runner.py, session-not-found arm of_run_chat: the requeue gate is now_should_suppress_requeue(slot) or _stop_pressed(), the same pairing every sibling requeue gate in_run_chatalready uses._stop_pressed()reads the slot's and the session's Stop generations live, so a resolved Stop is visible.Backwards compatibility
Compatible: a turn with no Stop behaves exactly as before (one reconnect replay). A turn whose Stop was pressed now ends without the replay, as it already did when the Stop was still in flight.
Removes nothing.
Tests
test_stop_resolved_before_the_error_never_queues_a_replayintest/test_chat_session_not_found_recovery.py: Stop moves the slot's Stop generation and resolves to idle mid-turn, then the backend answers "Session not found". Asserts one provider call, empty queue, no reconnect notice, one-shot not spent.test/test_chat_runner_composition_contract.py: 210 pass; the same 2 tests fail identically on untouched main locally (subprocess import environment), not touched by this change.chat_runner.py, comment-history (base origin/main), agent-sdk boundary: all pass.Manual verification
Covered by the unit test; the race is a Stop that resolves before the error is classified.
Related Issues
Fixes #16547. Follow-up to #16221; the release backport #16412 carries the same line.
Pattern harvest
Rule candidate: review-prompt
Pattern: every requeue/replay gate pairs
_should_suppress_requeuewith_stop_pressed; a gate that checks only the in-flight Stop state misses a Stop that already resolved to idle.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement