Repository navigation
Fail a blocked prompt, carry a switch after a limit, survive a sleep - #188
Merged
Merged
Conversation
A UserPromptSubmit hook that ends a message now fails the turn under a prompt blocked note quoting the hook's reason, instead of an empty reply saying nothing failed. A blocked history replay drops its empty session, so the next message replays again rather than going on without it. Also registers REFUSAL_FALLBACK_MARKER in PLUGIN_NOTE_MARKERS and adds a test that scans src/ for any marker missing from the list. h #g314
A turn that failed on a usage limit or an account block, answered by the CLI's own failure reply, leaves a session that holds its message, so its resume record is written. Before, a by-hand switch to another account after a limit replayed the whole thread (sibling-conversation-changed), and so did a restart. Other failures keep the replay. h #g315
The wire-inactivity watchdog counts wall-clock time, sleep included, so a sleeping Mac read as a silent CLI and closed a subagent's turn while its CLI only waited for the network; the CLI then ran on unattended for 28 minutes. A fire well past its deadline now waits a fresh delay, and a fire that closes the turn interrupts the CLI. h #g316
An api_retry frame says how long the CLI will wait before its next attempt; whichever watchdog is armed now waits that much longer, so a long backoff neither closes the turn nor respawns a working child. The start watchdog also re-arms on a late fire, like the inactivity one. h #g316
The TUI records a prompt a UserPromptSubmit hook ends as a system/informational record with promptSubmitEnding and nothing after it, so a PTY turn waited out its whole timeout, and it hands the text back to its input box, where the next paste joined it. End the turn on that record, clear the box with one Ctrl+C before the next paste, and hand the parser headless's frame and result so the note, the error finish and the blocked-replay drop are shared. Measured under a PTY on Claude Code 2.1.322 (h #g314).
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 message a Claude Code
UserPromptSubmithook ended read as an empty reply, and when that message was a history replay, the conversation's history was lost without a word (h #g314).What happened
On 2026-11-14, after a switch from Opus 5.5 (appical) to Fable 5.2 (default), the plugin replayed the thread as text. agent-guard's prompt guard blocked the replay ("it contains secret-like values"). Claude Code made no API call and reported
successwithnum_turns: 0, so the plugin showed▌ **no reply:**("Nothing failed"). It also recorded the empty Claude session as the one continuing the conversation, so every later message went to it with no history.Measured (Claude Code 2.1.293, 2.1.314, 2.1.322, scratch hook)
system/informationalframe withprompt_submit_outcome: {kind, prompt_kept, reason}andprevent_continuation: true, then asuccessresult withnum_turns: 0. 2.1.293 sends the frame without the outcome.contentand the result'sresultrepeat the whole original prompt, so only the outcome is read. Nothing logs either text.num_turns: 2).Change
{unified: "error", raw: "blocked_by_hook"}(or the CLI's other kinds) under a▌ **prompt blocked:**note quoting the hook's reason. There is nono replynote and noturnStatsfooter. The session is kept.REFUSAL_FALLBACK_MARKERwas never inPLUGIN_NOTE_MARKERS, so that note was replayed as Claude's words. It is registered now, and a test scanssrc/for any▌marker missing from the list.The interactive transport (measured under a PTY on 2.1.322)
system/informationalrecord withpromptSubmitEnding: {ending: {kind, reason}, promptKept}and writes nouserorassistantrecord after it, so a PTY turn waited out its wholeturnTimeoutMs. The turn now ends on that record.prompt_submit_outcomeshape with itscontent(the whole prompt) dropped, and the synthesized result is headless'snum_turns: 0success, so the note, the error finish and the blocked-replay drop are the headless code unchanged.ses_e2898d33effeo0ojQzfvfWVOJK) was this same block: agent-guard refused the replay into the worktree's new session key by size, 6 s after the step started.Why the switch replayed at all (h #g315)
The appical session hit its 5-hour limit twice before the switch. A resume record was only written after a served turn, so the limited turns' messages sat past it, and the by-hand switch to the default account refused the carry (
sibling-conversation-changed). Claude Code's transcript holds both limited turns (userrecord plus a<synthetic>rate_limitreply), so the session was intact. Now the record is also written after a turn that failed on a usage limit or an account block with the CLI's own failure reply. Other failures, such as a 529 or a too-long prompt, keep the replay. A restart after a limit benefits the same way.The watchdog and a sleeping Mac (h #g316)
The same evening a subagent's turn was closed as a stream timeout during a dark wake and its CLI ran on unattended for about 28 minutes. Its transcript and
pmset -g logshow the 60 s wire-inactivity timer counts wall-clock time, sleep included: it fired 3 s into a dark wake with at most 41 s of awake time behind it. A fire more than 5 s past its deadline now waits a fresh full delay, because the silence was never observed (a sleep, or an event-loop stall with output still in the pipe). A fire that does close the turn sends the CLI aninterrupt, as an abort does. The start watchdog follows the same late-fire rule, and anapi_retryframe makes whichever watchdog is armed wait out the backoff the CLI announces, so a long retry neither closes the turn nor respawns a working child. Proxied calls that arrive with no stream attached are unchanged (late-result recovery).Checks
npm run typecheck,npm test(2316 pass),npm run buildtest/prompt-blocked.test.tsdrives realdoStreamturns against a fake CLI replaying the measured frames, with a secret-like string that must reach neither the reply nor the logtest/account-groups.test.ts: a by-hand switch after a usage limit resumes the first account's session with no replay (fails without the change), and one after a 529 still replaystest/prompt-blocked.test.tsis skipped on Windows, like the other fake-CLI files; the parser and note tests run theretest/result-fallback-sleep.test.ts: a fire made ten minutes late by a jumped clock re-arms and the CLI's answer lands, and a closing fire sends exactly oneinterrupt; each fails with its change switched offtest/interactive-pty.test.ts: a scripted TUI that ends a prompt the measured way: the record and its stream frame, the synthesized result, a turn ended at once and one Ctrl+C before the next paste,askfailing, a queued message leaving its turn running, anddoStreamturns for the note and a blocked replay dropping its session