Repository navigation
Wake once for a prompt Escape dropped, which Claude Code submits again - #5066
Merged
Merged
Conversation
A watch read Claude Code's idle as the end of a turn nothing follows. A queued prompt that Escape drops during its prompt hooks is submitted again, and that prompt's hooks start the watch that takes over, so the dropped prompt's watch woke the session a second time for the same input when it looked in between. Claude Code's transcript holds no record of a dropped prompt, so the watch now waits for a successor after one, as it does after a Stop. Co-Authored-By: Claude Opus 5.5 <[email protected]>
leaf-agent
approved these changes
Nov 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A
leaf-dev journey claude-coderun on #4900 failed itsdroppedstep with two "Leaf: new input" wakes 90 ms apart for one comment ({'Stop hook wake': 2, 'empty': 1}). Both rows were background-watch wakes, so admission's nudge played no part. The run's transcript, Claude Code's debug log and the page's watch records show the sequence:idle, took the dropped turn for one Escape had stopped, and woke the session too. Claude Code queued that wake into the answering turn and attached it at the next tool boundary, where it had nothing to hand over.The change
later_turn_wakesreadidleas the end of a turn that nothing follows. That holds for a turn Escape stops while it runs. It doesn't hold for a queued prompt, such as a wake, that Escape drops during its prompt hooks: Claude Code submits that prompt again, and its hooks start the watch that takes over. A watch now treats such an ending as it already treated a Stop's: it wakes only if no successor has come within the hooks' time (20 s).Claude Code's transcript tells the two endings apart. It writes a prompt's record, which names its
promptId, only once the prompt's hooks let it through, and writes nothing of a dropped prompt (harness.claude_code_prompt_dropped, behind the newHarness.prompt_dropped). The watch now receives the hook payload, which names the transcript.Every wake is kept. A typed prompt Escape drops goes back to the composer and is not submitted again (probed on 2.1.316), so its watch still wakes the session for what the dropped prompt was handed: about 20 s after the Escape rather than at its next look within 5 s, or not at all if the user sends the prompt again first, whose own hook hands the input over. A payload naming no transcript, or a transcript that can't be read, reads as not dropped and keeps the immediate wake.
Evidence
test_a_prompt_escape_dropped_is_handed_its_input_again_after_one_wakereplaces the test that asserted the dropped prompt's watch wakes. Its[queued]case reproduces the journey's interleaving, a title write between the Escape and the resubmission, and fails without the new rule ("the dropped prompt's watch woke the session");[typed]checks the wake still comes once no successor does.test_wait.py,test_hooks.py,test_hook_registration.py, the layer contract's route test andtest_interact_pi.py(134 passed).leaf-dev journey claude-codepassed all 12 steps twice with no empty wake or notice, and--forkspassed its 6 steps. In those runs no dropped prompt's watch looked between the Escape and the resubmission, so they show the change breaks no step (woken, whose Escape stops a running turn, was still picked up 3.0 s after it) rather than reproducing the race; the[queued]test does that.Not changed
Admission's nudge can still interleave with a Stop hook's watch where no watch holds the session's lease at a Stop, as after the turn that first claims a page: input admitted between the Stop hook closing the turn and the Stop's watch taking the lease is nudged, and the watch then wakes for it too. A scratch model test reproduced it; no run has shown it. The watch can't skip its wake on the nudge's mark (
messaged_ending) without risking a lost wake, since a nudge that lands starts a turn only whereHarness.input_wakessays so, which takescrossSessionInbound: acceptin the user's settings.