Repository navigation
Conversation
88249b4 to
f984716
Compare
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] c23f4e2 Description read[DESCRIPTION-READ] aa0116294a666a63b6e9ee1237b812276730eedac3eb21fc702c770ee61206e2 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, fork) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS This patches three gates, but the root cause the description names, that " Not justified as shipped
What this change shipsInventory (4 items) — 3 justifiedIntent: a prompt the user stopped must not re-run on a fresh runtime after a runtime death or busy error. FIX.
[FIRST-PRINCIPLES-REVIEWED] c23f4e2 Description read[DESCRIPTION-READ] af305f564ace1370c02ce991cd8dbc670a0dbf927640b85b6e942711d1b03117 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
|
CI note on head
No push for these. A re-run after #16801 lands should clear shard 7. |
346f8ad to
da6213f
Compare
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>
The First Principles review of f984716 counted one more gate of the same class: `_requeue_after_prompt_busy`, behind the `PromptBusyExhaustedError` arm, still checked only for a Stop in flight. It now takes `_run_chat`'s live `_stop_pressed` read and pairs it with `_should_suppress_requeue`, like the other three arms. The regression test gains that error shape: red with only the source hunks reverted, green with them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
da6213f to
c23f4e2
Compare
|
Thanks @leonlaiyc for catching that the two sibling requeue arms still replay a resolved Stop — this is a real gap. Because this touches core-repo files, I've carried your change forward as a main-repo PR so it can run the full check + review suite: #18401 (Fixes #18400). It ports your fix verbatim (both chat_runner arms + _requeue_after_prompt_busy threaded with _stop_pressed) plus your test, rebased onto current main, and credits you as co-author. Closing this one in favor of #18401. Appreciate the follow-up to #16548! |
…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: A prompt the user stopped is not replayed on a fresh runtime when the runtime dies or answers busy after that Stop has already resolved.
#16548 (for #16547) fixed this on
_run_chat's lost-session arm. Both the Design and the First Principles reviews of that PR named the same gap on the sibling arms of the sameexceptchain. Two of those arms are still open on main @68782006c:except AcpProcessDied, the shared/own-death requeue), andexcept AcpErrorwhen_retry_eligible:AcpPromptBusy, "already in progress", "process exited", "not running").Each one gates its replay on
_should_suppress_requeue(slot)alone, and that check sees only a Stop that is still in flight. A Stop that pressed and snapped back to idle before the error reached the handler leaves_stoppingFalse and moves only the Stop counters. The arm therefore posts "⟳ Connection lost — retrying…" or "⟳ Session busy — retrying…" and queues the stopped prompt (for example "delete the old branches") for verbatim replay.Why it matters
Stop is how a user withdraws a request. Here the withdrawn request runs anyway, on a fresh runtime, with no further prompt. That covers any side effect the stopped prompt asked for. The trigger needs nothing unusual: a kiro-cli death or a busy answer that lands just after a Stop, which is when a stopped process is most likely to be torn down.
Not a goal
What changed (motivation → approach → change)
Symptom: a stopped prompt is replayed after a runtime death or busy answer. Root cause: these three gates read only the in-flight Stop. The replay goes through
_queue_recovery, which takes no Stop snapshot of its own, so nothing downstream can see a Stop that has already resolved._stop_pressed()reads the slot's and the session's Stop generations live against the turn's entry snapshot, which is exactly that signal.Change,
src/kiro_crew/dashboard/chat_runner.py:_should_suppress_requeue(slot) or _stop_pressed(), with a comment saying why only this gate can see a resolved Stop.Change,
src/kiro_crew/dashboard/chat_turn/recovery.py(commit 2, from the First Principles review off984716):_requeue_after_prompt_busy, the gate behind theexcept PromptBusyExhaustedErrorarm, takes_run_chat's_stop_pressedcallable and applies the same pairing. It is passed the callable, not a value, so the Stop is read live at the gate, as_stop_pressedrequires.All three arms'
passbranch is the existing behaviour for a Stop still in flight, so a resolved Stop now ends the turn the same way an in-flight one already did.Each reviewer-named sibling, graded on its own:
acp_error_is_session_not_found)AcpProcessDied)_retry_eligibleAcpError)AcpPromptBusyshapePromptBusyExhaustedError→_requeue_after_prompt_busy)PromptBusyExhaustedErrorshapeacp_error_is_transient,not _turn_emitted)_recovery_delayit re-reads_should_suppress_requeue(slot) or _stop_pressed()and drops the replay withTRANSIENT_GIVE_UP_TEXTThe 5xx arm's bare pre-backoff check only means a resolved Stop shows a "retrying" card, waits out one backoff, and then reports the give-up. That arm also resets its per-turn budgets on the drop path, so changing its gate is a separate change rather than one more line.
Backwards compatibility
Compatible: the only behaviour change is that these three arms no longer requeue after a Stop the user already pressed; with no Stop, each arm requeues exactly as before (pinned by the positive-control tests below).
Removes nothing: no route, key, field or function is removed or renamed; three existing gate conditions gain a second disjunct (
_requeue_after_prompt_busygains the keyword it reads it from; its only caller is_run_chat).Tests
New
test/test_chat_requeue_resolved_stop.pydrives the real_run_chatthrough a stubbed ACP client, in the same harness shape as #16548'stest_chat_session_not_found_recovery.py. There are four error shapes:AcpProcessDied, a pipe-deathAcpError("… process exited …"),AcpPromptBusyandPromptBusyExhaustedError. Each runs twice:test_the_arm_requeues_the_prompt_when_nothing_was_stopped[*]: the positive control. With no Stop, each arm posts its "retrying" card and replays the prompt once (calls == [msg, msg]). This proves the harness reaches the arm under test. It passes on main and with the fix.test_a_stop_resolved_before_the_error_never_queues_a_replay[*]: the Stop generation moves and_stoppingreturns to False inside the stream before it raises. The test asserts one call, an empty queue and no "retrying" card. Red on main for all four shapes (callsholds the replay), green with the fix. ThePromptBusyExhaustedErrorcase was re-checked at commit 2: with only the twosrc/hunks reverted, it fails and the other seven pass. With them applied, all 8 pass.Adjacent suites, run locally with the fix (
-n 6):test_dashboard_chat.py,test_gateway_pipe_death.py,test_session_idle_busy_guard.py,test_runtime_death_is_a_process_event.py,test_recovery_l1_chat_runner.py,test_chat_runner_composition_contract.py,test_chat_threads.py,test_refusal_inband_notice.py,test_chat_session_not_found_recovery.pyand the new file: 1275 passed, 3 skipped, 4 failed. The 4 failures aretest_chat_threads.pysymlink tests that fail identically with this change reverted (OSError: [WinError 1314], because creating a symlink needs elevation on the local Windows box); they never reach_run_chat.black --checkandflake8are clean on the changed files.At commit 2 (
346f8ad), all of these suites were re-run:test_chat_requeue_resolved_stop.py,test_chat_runner_composition_contract.py,test_chat_runner_coverage.py,test_dashboard_chat.py,test_gateway_pipe_death.py,test_llm_helpers.py,test_recovery_l1_chat_runner.pyandtest_runtime_death_is_a_process_event.py. Result: 1630 passed, 0 failed.flake8,black --check,isort --check-onlyandmypyonchat_runner.py+chat_turn/recovery.pyare clean, and so is the comment-history gate.Manual verification
N/A — unit coverage sufficient: the defect is a gate condition inside
_run_chat'sexceptchain, and the new tests drive that exact chain end to end with the Stop counters moved the way the dashboard Stop handler moves them, plus a positive control per arm.Related Issues
Follow-up to #16548 (for #16547): the sibling arms both of that PR's AI reviews named and the PR left out of scope. No separate issue was filed.
Pattern harvest
Rule candidate: review-prompt
Pattern: a requeue/replay gate that reads only the in-flight Stop state (
_should_suppress_requeue) without the Stop generation (_stop_pressed) misses a Stop that already resolved to idle; every replay arm that has no post-wait re-read needs both.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
🤖 Generated with Claude Code