Skip to content

fix(warp): take the Stop response from last_assistant_message - #108

Open
dlecan wants to merge 1 commit into
warpdotdev:mainfrom
dlecan:fix/stop-response-from-hook-input
Open

dlecan wants to merge 1 commit into
warpdotdev:mainfrom
dlecan:fix/stop-response-from-hook-input

Conversation

@dlecan

@dlecan dlecan commented Nov 18, 2026

Copy link
Copy Markdown

The Stop notification often has an empty body. Warp shows '<prompt>' finished and then Latest output: with nothing after it.

on-stop.sh waits 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 the terminalSequence of 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.sh reads the same field. This change:

  • reads last_assistant_message first;
  • falls back to the transcript when the field is missing, so older Claude Code versions behave as before;
  • applies the 200-character truncation to both sources.

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 through on-stop.sh as a subprocess with the modern protocol variables set:

  • transcript ending on a thinking-only entry, with last_assistant_message in the input: the response comes from the input;
  • same input: the query still comes from the transcript;
  • no last_assistant_message: the response comes from the transcript;
  • 250-character 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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant