MessageDisplay hook input has no stop reason
Preflight Checklist
- [x] I have searched existing requests and this feature hasn't been requested yet
- [x] This is a single feature request (not multiple features)
Problem Statement
MessageDisplay hook: please include the message's stop_reason (or an is_final_reply flag) in the hook input.
What happens: in a headless/SDK session the MessageDisplay hook receives turn_id, message_id (a fresh UUID, not the stored message id), index, final and delta. Nothing says whether the message is the closing reply of the turn (stop_reason end_turn) or text written before a tool call (stop_reason tool_use). The engine already has message.stop_reason when it calls the hook, and the message is written to the transcript only after the hook returns, so a hook cannot look it up either.
Why it matters: a hook that wants to hold back a closing reply that the Stop hook is about to block (so the user sees only the corrected reply, not two copies) cannot tell closing replies from in-between text. The workaround has to hold every failing message.
Ask: add stop_reason (and the real message id) to the MessageDisplay hook input.
Proposed Solution
Add two fields to the MessageDisplay hook input:
- stop_reason: the message's stop reason (end_turn, tool_use, max_tokens, ...), which the engine already has when it calls the hook.
- the stored message id (message.id), so a hook can match the displayed text to the transcript entry and to the Stop hook's input.
With stop_reason present, a display hook can hold back only a closing reply (end_turn) that the Stop hook will block and leave in-between text alone. Existing hooks are unaffected: the fields are additive.
Alternative Solutions
_No response_
Priority
Critical - Blocking my work
Feature Category
CLI commands and flags
Use Case Example
_No response_
Additional Context
_No response_