Repository navigation
fix(chat): let a resolved Stop veto the runtime-death and busy requeue arms - #18401
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] 52c5b19 Description read[DESCRIPTION-READ] 14926f132422c4b516bf834004426ec52a8abec9c696e435329d9b0b6252213e 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) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check the throttle-fallback arm at What this change shipsInventory (7 items) — 7 justifiedIntent: when a user stops a prompt and the runtime then fails during teardown, the stopped prompt should not run again on a fresh runtime. FIX (#18400; the PR's tests fail on base).
[FIRST-PRINCIPLES-REVIEWED] 52c5b19 Description read[DESCRIPTION-READ] 52a416f9ed709bd2c2f1e649fe925823e2c3544aa629941bc90a01457a1e7e4d That sha256 names the PR description this verdict read. Recompute it with |
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: |
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: |
|
Self-review (crew-pr-reviewer, read-only): CHANGES NEEDED This PR stops a Stop that already went back to idle from being replayed after a runtime death, a pipe death, a prompt-busy answer or busy exhaustion, by pairing each of those gates with |
|
Moved to draft by crew-pr-reviewer: the self-review above is CHANGES NEEDED. GitHub refuses a self-request-changes and the readiness check ignores human reviews, so draft keeps this PR from merging (it also turns auto-merge off). Once the points above are fixed, mark it ready with |
c7caa2f to
54f5b80
Compare
|
Fixed on head
Local: the new file 12/12; 36 related test files (image/transient/stop recovery, |
54f5b80 to
77ac9c3
Compare
|
Head
|
77ac9c3 to
6461b59
Compare
|
Self-review (crew-pr-reviewer, read-only): CHANGES NEEDED This PR stops a Stop that already went back to idle from being replayed after a runtime failure. It pairs each requeue arm's |
|
Converted to draft by crew-pr-reviewer: the self-review above is CHANGES NEEDED. Mark ready again (gh pr ready 18401) once the points are addressed. |
…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>
6461b59 to
30f0588
Compare
|
Re the CHANGES NEEDED self-review of 2026-10-11 00:23Z. Fixed on head
Local: the test file passes 15/15. 939 passed across the related recovery/transient/prompt-busy/steer/composition-contract files, and 903 passed in |
…set 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).
30f0588 to
52c5b19
Compare
|
Head is now |
Problem / Motivation
Goal: A Stop the user already pressed can no longer be replayed on a fresh runtime after a mid-turn runtime failure.
_run_chatre-queues a turn when the provider dies or a prompt-busy retry runs out. Each arm must veto the replay when the user pressed Stop. Merged #16548 fixed only the lost-session arm. Six arms still gate on_should_suppress_requeue(slot)alone, so a Stop that resolved to idle before the error reached the handler (invisible to the suppress check) still queues the stopped prompt for replay.Why it matters
Without this, a user who Stops a prompt and then hits an unrelated runtime death during the same teardown has the cancelled prompt silently replayed on the fresh runtime — the agent runs work the user explicitly stopped.
Not a goal
_should_suppress_requeue, the Stop counters, or_queue_recovery— only the arm gates read the resolved-Stop signal._stop_pressed()pairing fix(chat): let a resolved Stop veto the lost-session reconnect replay #16548 established.What changed (motivation → approach → change)
_should_suppress_requeuereads only an in-flight Stop (_stoppingTrue). A Stop that snapped back to idle leaves_stoppingFalse and moves only the Stop counters, which_stop_pressed()reads. The replay path_queue_recoverytakes no Stop snapshot of its own, so each arm's own gate is the only place a resolved Stop can be seen._stop_pressed()— the runtime-death arm and the prompt-busy / pipe-death arm inchat_runner.py— and thread_stop_pressedinto_requeue_after_prompt_busy(chat_turn/recovery.py) so the post-busy-exhaustion helper can read it too. The image-history recovery (image_format_unsupported, which discards the conversation and replays the prompt on a fresh session) gets the same pairing on its non-owed replay condition; its owed-completion half is unchanged. The poisoned-conversation reset arm (canary probe, conversation discard, verbatim replay) gets the same pairing: its_stop_gen_before_canarysnapshot, like_image_stop_gen, is taken after a resolved Stop already moved the counter. The transient-5xx arm's first gate gets its own resolved-Stop branch, so a resolved Stop no longer flashes a "retrying" card the post-backoff re-read then 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 would shorten the next turn's 5xx ladder. Every other arm uses the identical one-line pairing to the lost-session arm.Why per arm and not inside
_queue_recovery:_queue_recoveryalso queues an owed sub-agent completion (_requeue_owed_completion,_replay_owes_delivery), which by contract no Stop cancels. A blanket Stop veto there would drop a result the parent is still owed.Deferred: the post-token transient helper (
chat_turn/acp_recovery.py_will_recover) can still show a "resuming…" card that its own post-backoff re-read withdraws. It replays nothing, so it is a display-only flash left for a follow-up.Backwards compatibility
Compatible: adds a disjunct to existing requeue gates and one keyword argument to an internal helper; nothing that works today stops working. A resolved Stop that previously replayed now (correctly) does not.
Tests
test/test_chat_requeue_resolved_stop.py(new): parametrised over six arms (runtime death, pipe death, prompt-busy, post-busy-exhaustion, image-history, transient-5xx), plus a two-cycle poisoned-reset pair (positive control discards and replays once; a Stop resolved on the last attempt discards nothing). The file patches the runner's_recovery_delayseam, not a process-wideasyncio.sleep. Each case runs twice — a positive control proving the arm replays once when nothing was stopped, and the stopped case proving a Stop resolved before the error queues no replay and shows no "retrying" card. A budget case checks that a resolved Stop on a transient 5xx leaves all four retry/fallback fields at zero for the next turn. 15/15 pass locally. All seven stopped cases (process-died, pipe-death, prompt-busy, prompt-busy-exhausted, image-history, transient-5xx, poisoned-reset) fail on the base commit (currentmain), and the budget case fails on the previous head.Manual verification
N/A — the behaviour is a race between a Stop and a runtime failure during turn teardown, reproduced deterministically by the new unit tests rather than by hand.
Screenshots / video
N/A — no user-visible surface changes; the fix is a backend requeue gate.
Related Issues
Fixes #18400
Replaces #16767 by @leonlaiyc
Pattern harvest
Rule candidate: review-prompt
Pattern: a turn-teardown requeue arm gates on
_should_suppress_requeue(slot)alone — any arm that can replay a prompt must also read_stop_pressed(), because a Stop resolved back to idle is invisible to the suppress check.Checklist