Feature request
Add a hook event that fires after an assistant text content block finishes streaming and before the next tool call is dispatched — or, equivalently, add a preceding_text (or current_message_text) field to the PreToolUse hook payload containing the assistant text emitted earlier in the same turn.
Problem
When the assistant emits preamble text and then calls a tool in the same turn, sidecars/integrations that hook on PreToolUse cannot see that preamble:
- The preamble has not yet been flushed to
transcript_path when PreToolUse fires — reading the JSONL at that moment returns the prior turn's content.
- No hook payload field carries the in-flight assistant text.
PostToolUse / Stop are too late for sidecars that render UI alongside the tool call itself (e.g., a custom UI for AskUserQuestion).
This is especially painful for AskUserQuestion: the model's preamble text often contains the why of the question, but the UI rendering the question can't access it. Users see a question without context.
Hook events checked (none expose in-flight text)
PreToolUse, PostToolUse, UserPromptSubmit, Notification, Stop, SubagentStop, PreCompact, SessionStart, SessionEnd — all receive tool_name/tool_input/transcript_path/session_id, but none carry the assistant message currently being streamed.
Proposed solutions (either would unblock)
A. New hook event: AssistantTextComplete — fires after each content_block_stop for a text block, before the next tool_use block is dispatched. Payload includes the completed text and the in-flight message_id.
B. Augment PreToolUse — add a preceding_text field containing all assistant text content blocks emitted in the current turn before this tool call.
(B) is the smaller change and solves the immediate use case. (A) is more general and would also unblock streaming sidecars, live transcripts, partial-message indexers, etc.
Use cases
Workarounds today
- Prompt the model to embed preamble inside
tool_input (e.g., AskUserQuestion description). Brittle, relies on model compliance, doesn't help other tools.
- Long-running daemon tailing
transcript_path. Still races flush timing, and isn't a hook.
Related
Feature request
Add a hook event that fires after an assistant text content block finishes streaming and before the next tool call is dispatched — or, equivalently, add a
preceding_text(orcurrent_message_text) field to thePreToolUsehook payload containing the assistant text emitted earlier in the same turn.Problem
When the assistant emits preamble text and then calls a tool in the same turn, sidecars/integrations that hook on
PreToolUsecannot see that preamble:transcript_pathwhenPreToolUsefires — reading the JSONL at that moment returns the prior turn's content.PostToolUse/Stopare too late for sidecars that render UI alongside the tool call itself (e.g., a custom UI forAskUserQuestion).This is especially painful for
AskUserQuestion: the model's preamble text often contains the why of the question, but the UI rendering the question can't access it. Users see a question without context.Hook events checked (none expose in-flight text)
PreToolUse,PostToolUse,UserPromptSubmit,Notification,Stop,SubagentStop,PreCompact,SessionStart,SessionEnd— all receivetool_name/tool_input/transcript_path/session_id, but none carry the assistant message currently being streamed.Proposed solutions (either would unblock)
A. New hook event:
AssistantTextComplete— fires after eachcontent_block_stopfor atextblock, before the nexttool_useblock is dispatched. Payload includes the completed text and the in-flightmessage_id.B. Augment
PreToolUse— add apreceding_textfield containing all assistant text content blocks emitted in the current turn before this tool call.(B) is the smaller change and solves the immediate use case. (A) is more general and would also unblock streaming sidecars, live transcripts, partial-message indexers, etc.
Use cases
AskUserQuestionwith the preamble as context.includePartialMessagesSDK request — V2 persistent sessions should supportincludePartialMessagesfor streaming token output #41732 — is the SDK-side equivalent).Workarounds today
tool_input(e.g., AskUserQuestiondescription). Brittle, relies on model compliance, doesn't help other tools.transcript_path. Still races flush timing, and isn't a hook.Related
includePartialMessagesfor streaming token output #41732 — V2 persistent sessions should supportincludePartialMessagesfor streaming (SDK-side request for the same underlying signal).