Repository navigation
Conversation
The Stop hook often runs before Claude Code has written the final text block to the transcript, even after the 0.3 s delay. The payload then carries an empty response and Warp shows "Latest output:" with nothing after it. Claude Code passes that text in the hook input as last_assistant_message, which on-stop-failure.sh already reads. Use it first and read the transcript only when the field is missing, for older Claude Code versions. The 200-character truncation applies to both sources.
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.
The Stop notification often has an empty body. Warp shows
'<prompt>' finishedand thenLatest output:with nothing after it.on-stop.shwaits 0.3 s, then reads the last assistant message from the transcript. When the hook runs, the transcript frequently ends on a thinking-only entry because the final text block has not been written yet. I decoded theterminalSequenceof every Stop hook recorded in my transcripts on Linux (Claude Code 2.1.x, Warp stable): 1,148 of 2,119 payloads had"response": "", 46 % in October and 60 % in November.Claude Code already sends the reply in the Stop hook input as
last_assistant_message(checked against the hook schema in Claude Code 2.1.327).on-stop-failure.shreads the same field. This change:last_assistant_messagefirst;The query still comes from the transcript. The user prompt is written at the start of the turn, so it is not affected by the race.
Tests
Four cases in
tests/test-hooks.sh, run throughon-stop.shas a subprocess with the modern protocol variables set:last_assistant_messagein the input: the response comes from the input;last_assistant_message: the response comes from the transcript;last_assistant_message: the response is truncated to 200 characters.The first and last fail on
main. The suite reports 70 passed, 0 failed.Not in this PR: the byte-level truncation in #70 and the synthetic-entry titles in #78 and #86.